Question

write piece of c code for the instruction below When the last character (the 16th) has...

write piece of c code for the instruction below

When the last character (the 16th) has been received, set a flag to notify the main program that a complete message has been received and is ready to be displayed.

ISR(USART_RX_vect)
    {
        char ch;

        ch = UDR0;                  // Get the received charater

        // Store in buffer

        // If message complete, set flag
    }
0 0
Add a comment Improve this question Transcribed image text
Answer #1

struct msg_buffer {

    long msg_type;

    char msg_text[100];

} message;

  

int main()

{

    key_t key;

    int msgid,flag;

    key = ftok("progfile", 65);

    msgid = msgget(key, 0666 | IPC_CREAT);

    message.msg_type = 1;

  

    printf("Write Data : ");

    gets(message.msg_text);

if( msgsnd(msgid, &message, sizeof(message), 0);)

flag =0

    printf("Data send is : %s \n", message.msg_text);

    return 0;

}

struct mesg_buffer {

    long mesg_type;

    char mesg_text[100];

} message;

  

int main()

{

    key_t key;

    int msgid,flag;

    key = ftok("progfile", 65);

    msgid = msgget(key, 0666 | IPC_CREAT);

if ( msgrcv(msgid, &message, sizeof(message), 1, 0); )

flag=1;

    printf("Data Received is : %s \n", message.msg_text);

    msgctl(msgid, IPC_RMID, NULL);  

if (flag ==1)

print('msg read");

    return 0;

}

Add a comment
Know the answer?
Add Answer to:
write piece of c code for the instruction below When the last character (the 16th) has...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Edit a C program based on the surface code(which is after the question's instruction.) that will...

    Edit a C program based on the surface code(which is after the question's instruction.) that will implement a customer waiting list that might be used by a restaurant. Use the base code to finish the project. When people want to be seated in the restaurant, they give their name and group size to the host/hostess and then wait until those in front of them have been seated. The program must use a linked list to implement the queue-like data structure....

  • Please read the problem carefully and answer the 2 questions below code: /***************************************************************** * Program: palindrome.c...

    Please read the problem carefully and answer the 2 questions below code: /***************************************************************** * Program: palindrome.c * * Purpose: implements a recursive function for determining *   if a string is a palindrome * * Authors: Steven R. Vegdahl, Tammy VanDeGrift, Martin Cenek * *****************************************************************/ #include #include #include /***************************************************************** * is_palindrome - determines whether a string of characters is a palindrome * * calling sequence: *    result = is_palindrome(str, first_index, last_index) * * parameters - *    str - the string to test *    first_index -...

  • Do this using the C language. show me the code being executed and also copy and...

    Do this using the C language. show me the code being executed and also copy and paste the code so i can try it out for myseld Instructions A cipher is mirrored algorithm that allow phrases or messages to be obfuscated (ie. "scrambled"). Ciphers were an early form of security used to send hidden messages from one party to another. The most famous and classic example of a cipher is the Caesar Cipher. This cypher worked by shifting each letter...

  • In basic c develop the code below: (a) You will write a program that will do...

    In basic c develop the code below: (a) You will write a program that will do the following: prompt the user enter characters from the keyboard, you will read the characters until reading the letter ‘X’ You will compute statistics concerning the type of characters entered. In this lab we will use a while loop. We will read characters from stdin until we read the character ‘X’. Example input mJ0*5/]+x1@3qcxX The ‘X’ should not be included when computing the statistics...

  • Code in c++ please fix all errors that’s being asked to find and please follow instructions...

    Code in c++ please fix all errors that’s being asked to find and please follow instructions ------------------------------------------------- // This is example code from Chapter 6.7 "Trying the second version" of // "Software - Principles and Practice using C++" by Bjarne Stroustrup // /* This file is known as calculator02buggy.cpp I have inserted 5 errors that should cause this not to compile I have inserted 3 logic errors that should cause the program to give wrong results First try to find...

  • Write a program that uses a recursive function to determine whether a string is a character-unit...

    Write a program that uses a recursive function to determine whether a string is a character-unit palindrome. Moreover, the options for doing case sensitive comparisons and not ignoring spaces are indicated with flags. For example "A nut for a jar of tuna" is a palindrome if spaces are ignored and not otherwise. "Step on no pets" is a palindrome whether spaces are ignored or not, but is not a palindrome if it is case sensitive. Background Palindromes are character sequences...

  • *********************C++ program*********************** ( I have tried to write this code in c++ atleast 10 and I...

    *********************C++ program*********************** ( I have tried to write this code in c++ atleast 10 and I cant get the outputs to print correctly) The purpose of this challenge is to use the IF, IF-ELSE-IF and nested IF statements to control program flow. This simulates the credit underwriting process for a loan. Requirements Be sure to look at the sample interaction below to help your understanding of these requirements Declare an integer: int score Declare the following chars: char discharged, bankruptcy...

  • Retrieve program randomAccess.cpp and the data file proverb.txt from the Lab 14 folder. The code is as follows: #include...

    Retrieve program randomAccess.cpp and the data file proverb.txt from the Lab 14 folder. The code is as follows: #include <iostream> #include <fstream> #include <cctype> using namespace std; 327 int main() { fstream inFile("proverb.txt", ios::in); long offset; char ch; char more; do { // Fill in the code to write to the screen // the current read position (with label) cout << "Enter an offset from the current read position: "; cin >> offset; // Fill in the code to move...

  • Write a program in 68K assembly code that adds an odd parity to each ASCII character....

    Write a program in 68K assembly code that adds an odd parity to each ASCII character. Your code must satisfy the following specifications: 1. Define the following 64 characters in the SRC address.SRC:DC.B 'Computing and Software Systems, University of Washington Bothell' 2. Define the 64-byte space.DST:DC.B 64 3. Read each of the 64 characters, (i.e., each byte) into D0, check the number of 1s in it, set 1 to the MSB with "ORI.B #$80, D0" to create an odd parity,...

  • Write a program that replace repeated three characters in a string by the character followed by 3...

    Write a program that replace repeated three characters in a string by the character followed by 3. For example, the string aabccccaaabbbbcc would become aabc3ca3b3cc. When there are more than three repeated characters, the first three characters will be replaced by the character followed by 3. You can assume the string has only lowercase letters (a-z). Your program should include the following function: void replace(char *str, char *replaced); Your program should include the following function: void replace(char *str, char *replaced);...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT