• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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: 9742
80
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • 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:

?
 
Sheriff
Posts: 27456
88
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