• Post Reply Bookmark Topic Watch Topic
  • New Topic

Additional byte when reading from OutputStream

 
Radoslaw Sztando
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,

I'm writing an application which communicates with some electronic
device by serial port.
I'm using javax.comm library (class SerialPort).

I wrote some test cases to test if communication works. Device just
sends 128 bytes starting from 0 to 128.
The problem appears that when device sends byte 0x0A application receives two bytes 0x0D and 0x0A.
It looks like Windows end-of-line. Can I somehow modify OutputStream mode (from "ascii" to binary)?

Any help will be appreciated.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DO you mean writing to OutputStream ?
 
Radoslaw Sztando
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
InputStream - sorry for confusion.
I read data from InputStream using read() method.
 
Vlado Zajac
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
InputStream should be always binary. (Readers and Writers work with text.)
[ September 25, 2006: Message edited by: Vlado Zajac ]
 
Radoslaw Sztando
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not good :/
What's more when I use standard win32 HyperTerminal I got correct sequence.
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a small snippet of code (say, < 200 lines) that exhibits this behavior?
 
Radoslaw Sztando
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can post some code (when I'll get home). Another thing is that I tried to connect COM1 and COM2 using cable and run two Java applications one is writing to COM1 and second is listening on COM2. Sequence was sent correctly - without any additional bytes. So I cannot reproduce it without this specific configuration.

I forgot to mention that electronic device is connected to USB and its drivers simulate it as RS232 port.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!