• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calculing the Checksum and adding it to the outputstream

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I'm having problems for calculating the checksum of a message that aI have to send to a serial port.

I don't understand the manual and I don't know how to do it.

I have a method that send the message to the Outputstream including the STX and ETX but I don't know how to include the checksum.

Here is what I have:




Reading the manual I have this information:

The standard LRC is calculated using a seed value of 0, and bitwise XORing each byte following the STX, including the ETX. This value is transmitted as a single ASCII character immediately following the ETX as the fincal character of the record.


Any of you can help me ? I 'm really lost.....

Thank you in advance for your help.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Paul pointed out in your previous post, bytes and Strings are different things. Converting them back and forth is a Bad Idea.
Have you tried to calculate the checksum? The Java Tutorial covers bitwise operations. What more do you need to know?
 
Jaume Guillamon
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I have solved with your help the send of bytes. I will work with bytes now.

Here the Method:


[ October 30, 2007: Message edited by: Jaume Guillamon ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic