• 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

QBASIC PRINT --> COM port OutputStream.write()

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what about writing to a port from Java in ASCII mode...I think this may be the problem, but not sure how to go about it?
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Jules
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how about flushing the stream?
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
JulianInactive KennedyInactive
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

Jules
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't tried that. I'll have a look into it, cheers. Arghhhhh, I really need to crack this one, it's winding me up..feels like
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps the QBASIC also sends a <cr><lf> or similar line termination?
Bill
 
Did Steve tell you that? Fuh - Steve. Just look at this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic