I am trying to establish serialport communication between my EFTPOS terminal which is connected to serialport and my computer. The EFTPOS manual has a C# code for testing and in that they have the following lines to write to the port and read from the port straightaway.
开发者_开发技巧port.WriteLine("@PL");
Console.WriteLine(port.ReadLine());
But in java if i use that my application goes into halt. So i am using eventhandlers in java to read the response from the EFTPOS terminal. Still i couldnot get it work. Now i have a doubt with the WriteLine("@PL") of C# and OutputStream.write(bytearray) of java. Are these 2 methods phrases the string in the same whay when it is written on the port ?? Because the EFTPOS will respond only if the message is "@PL". A solution to this problem will be a great relief for me..
It's possible that they're writing in different encodings. If the EFTPOS terminal is expecting ASCII and Java is writing UTF-16, it won't work.
精彩评论