This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

RS232 Protocol characters How TO ?  RSS feed

 
Jaume Guillamon
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI all,

I have a program that read messages From rs232 And I have to implement some code in order to capture the hex codes that permits to know when the message begins and when the message ends.

This are the codes I have to capture:

<STX> is 02h and <ETX> is 03h. <ACK> (06h), <NAK> (15h) or <ENQ> (05h). As well I have to calculate the <CRC> checksum byte.

Do you know how to implement it ?

At this moment my code has an event listener that read the buffers:



Thank you in advance for your help.
 
Jaume Guillamon
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'll apreciatte very much any comment regarding this issue, I have to solve it as soon as posible.

Do you know some internet page with some information about it ?

Thank you in advance for your help.

regards.
 
Joe Ess
Bartender
Posts: 9425
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what your question is. You have code that reads from a port. You know what characters you are trying to find. What is the problem? Have you tried running your code? What happened?
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One comment I would make: the bytes you are looking for are not text, they are control characters. So converting them to a String is a bad strategy. Leave them as bytes and deal with them as bytes.
 
Jaume Guillamon
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you booth for your answers,

Yes I know that I have control characters, but I don't know how to ask if this byte is a 02h... I never have been working at this level (bytes).

Thanks again.
 
Joe Ess
Bartender
Posts: 9425
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the Java Tutorial page on data types and see if that clears things up.
 
Jaume Guillamon
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joe,

I have been solved this, I have another one more difficult, see my last post HOW to Calculate the Checksum and send it to the outputstream.

Thanks
 
Jaume Guillamon
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joe,

I have been solved this, I have another one more difficult, see my last post HOW to Calculate the Checksum and send it to the outputstream.

Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!