• Post Reply Bookmark Topic Watch Topic
  • New Topic

RXTX Bug on Win 7 64 bits

 
Vinicius Alves
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

I'm trying to make a direct communication with a POS printer emulator , the problem is , to the emulator execute the command I write by the OutPutStream write method wich I get from SerialPort.getOutputStream , I have to run the application twice on eclipse , but if I run the application twice and open the serial port on any other application , the command is executed again.
Does anyone know what could it be ?
I've tried to run the same code on a virtual machine Virtual Boxrunning win XP 32 , but still the same way .

I tried to use the CloudHopper version dll's compiled for win vista 64 , but It didn't work the same way and JavaComm does the samething
does anyone knows if it is a bug on win 7 or if it is a problem with my code.
Thank You all !!!


 
Stephan van Hulst
Bartender
Posts: 6583
84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need to run the program twice?
 
Vinicius Alves
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:Why do you need to run the program twice?


If I run the application twice ,the POS printe emulator executes normally the command I send to it .
or
If I run the application twice,the POS printe emulator executes normally the command I send to it and after that if I open the port again with any other application the emulator execute again the command.

Seems like the command stay buffered , but I flush(); and close(); the outputstream .
 
Stephan van Hulst
Bartender
Posts: 6583
84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but why don't you just run the program once?
 
Vinicius Alves
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:Yes, but why don't you just run the program once?


Thats the problem , if I run the application only once , nothing happens , the POS printer emulator does not print anything . only after the second time .
If I run once the app and open the serial port with another application "Delphi made" , the emulator just prints the command I just sent using the eclipse. I've tried so many things and configurantions on the SerialPort object and nothing happens , just continue the same reaction.

thanks you.
 
Stephan van Hulst
Bartender
Posts: 6583
84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, just run the program once, and try to fix that problem.

It seems like the device reads from the serial buffer before you get a chance to write anything to it. Then it stops reading once the buffer is empty. I believe there's a signal you can send to the serial port controller that will tell the printer that there is new data in the buffer, waiting to be read. Try calling setRTS(true) in your serial port *after* you write your data. I believe this channel might automatically be reset after the device on the other end finishes reading from the UART buffer, but I am not sure.

Also, have you set the DTR at the beginning using setDTR(true)?
 
Vinicius Alves
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if it helps , but is I'm debug the app , the emulator prints correctly the receipt , but if I run the application normally on eclipse , I have to run twice to make it work once.
 
Stephan van Hulst
Bartender
Posts: 6583
84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I don't really know how to help you there. It sounds like a shortcoming in Eclipse to me.
 
Vinicius Alves
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Stephan van Hulst , it worked.

I've tried to setDTR(true); before and it wasn't working , but the problem was , because I was closing the port before the Emulator gives me the response , and then I read till the count of bytes I want or till the timeout expires, and it worked .

You helped me a lot , thank you very much Stephan van Hulst !

Here is the code working.


 
Stephan van Hulst
Bartender
Posts: 6583
84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great, I'm glad you managed to sort it out
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!