开发者

difference between c# and java write()

开发者 https://www.devze.com 2023-03-01 23:36 出处:网络
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 fol

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消