I’m not sure this is the right forum for this question and hope you’ll redirect me to the right one if not.
I’m trying to write some code using MicroC/OS II from Rabbit for an RCM5700 module. What I need to know is how to set up an interrupt driven serial routine that will collect characters from a MODBUS command that comes in over a serial port and then can notify a task that is waiting for a command to parse.
I really don’t want to be bothered until an entire command has been received. The commands ALL start with a colon ( and end with a CR/LF pair. At this point, I don’t care whether this command is for my board or some other board in the system, I’ll check that on each incoming command.
I would like to have an ISR to do the following:
- Receive a character
- If it is a colon, set an “In Command” flag
else if the “In Command” flag is set, add this character to the end of the command we are building
else (we are NOT building a command) throw the character away
end if - If it is a CR, throw away the character
- If it is a LF, notify the task that is waiting for a complete command that one is available (this task will have to copy the text of the message into it’s own space from the ISR I think)
- Clear the “In Command” flag so we can wait for the next one.
I have the MicroC/OS II book from Rabbit but can’t seem to find any info about creating an ISR task for reading incoming characters and creating a buffer to hold these characters until a LF comes in.
Thanks in advance for any help!
Len Morgan
CRMWD