Shop OBEX P1 Docs P2 Docs Learn Events
Help with serial I/O — Parallax Forums

Help with serial I/O

mynet43mynet43 Posts: 644
edited 2011-06-18 09:45 in Propeller 1
I have a new board, with serial I/O coming in thru a MAX232 chip. I'm going to run it at 57600 baud.

Here's my issue. I'm receiving I/O from a PC, acting as master. The format of the messages is:

Regular messages:
<SOH>[ID][LENGTH][CMD][PARAM1][PARAM2]...[PARAMn][CRC16]<EOF>

ACK/NAK:
<SOH>[ID][LENGTH][CMD][CRC16]<EOF>

Two questions:
1. Can someone recommend a driver that supports this SOH/EOF format? Or do I need to modify an existing driver?

2. Is there an available CRC16 routine for this type of message?

Thank you for your help and support.

Jim

Comments

  • LeonLeon Posts: 7,620
    edited 2011-06-18 07:48
    You will have to write your own software for that protocol, using the low-level code provided in the Obex. There is some CRC code there, as well.

    I've done something similar in C for an ARM device, using a 32-bit CRC. It was quite easy.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-06-18 07:58
    1) This sort of thing isn't normally handled by the I/O driver. It's handled by the software layer that calls the I/O driver. You'll have to supply that.

    2) I'm not aware of any, but there are lots of examples available with a web search. Look at the Wikipedia.
  • mynet43mynet43 Posts: 644
    edited 2011-06-18 07:58
    Hi Leon,

    Thanks for the quick update. I was afraid of that. Not too difficult, just one more thing...

    If anyone else has done some of this, please let me know. Also the CRC16.

    Thank you for your help.

    Jim
  • mynet43mynet43 Posts: 644
    edited 2011-06-18 08:04
    Hi Mike,

    Are you saying to just use the RX routine to grab bytes and do the checking myself?

    I'm used to receiving strings terminated by CR, etc.

    Thanks for the help.

    Jim
  • idbruceidbruce Posts: 6,197
    edited 2011-06-18 08:32
    @mynet

    Check this out for size.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-06-18 08:39
    The Dynamixel servos use a similar protocol. You might want to look at the driver in the OBEX.

    What device are you using? Maybe someone on the forum has already written code for it.

    According to ASCII <SOH> (start of header) would be 1. I didn't see an ASCII for
    <EOF> (I'm guessing end of file). There is an <EOT> (end of transmission) 4.

    Duane
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-06-18 08:55
    Jim,

    Your comm protocol has some similarities to the YMODEM protocol. It uses SOH, EOT and a 16-bit CRC. My YMODEM routines are attached below. They are spinix apps, but I think it contains some of the basic code that you need. Let me know if you have any questions.

    Dave

    BTW, the attached programs are based on a thread that Rayman started in the old forum about YMODEM.
  • mynet43mynet43 Posts: 644
    edited 2011-06-18 09:42
    Wow! Thanks for all the great feedback.

    @Duane - I think you're right about the EOF vs EOT. The EOT makes sense, the EOF was in the spec I received from my customer. Probably a typo.

    @ Bruce and Dave - Thanks for the software! I'll look at all of them. I think you just saved me some precious time.

    Thanks again for the help and support.

    Jim
  • idbruceidbruce Posts: 6,197
    edited 2011-06-18 09:45
    @Jim - You are entirely welcome. It is nice to get a thank you, some of these guys don't even bother to say thanks. I don't know if my stuff will help you, but it just might. It has a similar protocal
Sign In or Register to comment.