• 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

Translate to java?

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Translate to java?
Hi
W hava a rs232-communication protocol script that I don't understand, and it is not shown what language the example is) do you have any idea what itshould doing?

Example :


I think is as a XOR for check if it is the end of messages or so..
But how do I use it and translate this to Java?
And get the real data out. ..
 
Saloon Keeper
Posts: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For 'unsigned char' use 'byte'. For 'char*' use 'byte[]'.
See if that helps.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Niklas Karlsson wrote:W hava a rs232-communication protocol script that I don't understand, and it is not shown what language the example is)


Looks like C to me.

do you have any idea what it should doing?


No, but I have an idea what it IS doing: It's returning a 7-bit checksum for a string (or possibly stream) of characters - which are equivalent to a byte in Java.

Basically, it's an error-checking method.

HIH

Winston
 
Niklas Karlsson
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok so if it is a checker, what can be the whanted return value?
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Niklas Karlsson wrote:Ok so if it is a checker, what can be the wanted return value?


The checksum. That's how they work.

The normal thing is that something, somewhere sends (or reads) the checksum first, and then compares the result with what it expects it to be.

Not knowing the RS232 protocol in detail, I can't tell you how that's done, but that's the general principle.

Winston
 
Niklas Karlsson
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carey Brown wrote:For 'unsigned char' use 'byte'. For 'char*' use 'byte[]'.
See if that helps.


So:

?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The latter code is probably better, since Java has a way of finding the size of an array but C doesn't. So it would be preferable to use the latter code IF, IF... the value of Len is actually the length of the array in the first parameter. I would assume that's the case, why would you want the checksum of part of an array, but it would be worth checking the code which calls this method to confirm.
 
reply
    Bookmark Topic Watch Topic
  • New Topic