Hi ranchers. A quick question that someone with some QBASIC experience might be able to clear up v.quickly.
I'm porting an old QBASIC program that communicates with a piece of scientific hardware over COM1 on a win pc. I can see from console output of both programs that the string I'm building for each command ready to send to the port is the same, yet the Java version doesn't get the right response - in fact it just get's a DLE (data link escape) followed by a NAK (negative acknowledge) response character every time. It struck me that maybe the Java...
is doing something different to...
...i.e. maybe command.getBytes() is wrong, sending the message in the wrong format or something. I also wondered whether byte order might have any influence on the bytes sent/received. Any ideas about this gratefully received as this task is a little out of the ordinary for me and I'm out of my depth. Cheers.
[ August 13, 2004: Message edited by: Ben Wood ] [ August 13, 2004: Message edited by: Ben Wood ]
I don't think byte order can have an influence unless you have more than one byte in a data type, e.g. short, int, etc. Since you're dealing with "byte" that's not a factor.
I think it may be a charset issue. There's a version of String.getBytes() that takes a charset. The charset you use will have to be the same as used by the original software and as expected by the hardware.
Cheers guys. I just tried the two suggestions and it didn't make any difference unfortunately. I think what I really need is an example Java application that can be used to send any command string to the device and read what comes back to see if I get the same result. Any pointers to such a test app?
Originally posted by Ben Wood: I can see from console output of both programs that the string I'm building for each command ready to send to the port is the same
Have you tried writing out the binary (or hex) values for what you're actually sending? I think that it's possible for different things to look the same on the screen. Still kinda clinging on to the charset thing really, but if you are sending the exactly same thing I see no reason why you wouldn't be getting the same response.