I’m sending data through serial port to “Verifone VX520” payment device. It is my first trial to communicate with such devices
SerialObj.Open(); string input = "02hPUR.10.99._000000000004.634._4761739001010010FFFFF.0808.123456.
.03h"; byte[] asciiBytes = Encoding.ASCII.GetBytes(input); SerialObj.Write(asciiBytes, 0, asciiBytes.Length);
As per the structure this message should send some amount and appear it on the machine but what I got is only this message “Sending Ack” And when I tried to read acknowledgment I got only this character
it is like upside down "T"
So, is there any way to know what’s going wrong here.
Most Verifone terminals use a special message formatting to transfer information between a PC and the software inside. Your payment string is wrong. The reply from the terminal is correct. 21 decimal is 15h NAK meaning message is wrong or crc wrong. Your string has to look like this "\02PUR.10.99._000000000004.634._4761739001010010FFFFF.0808.123456. .\03" but i really doubt that the dots are really dots and not Field Separators that code with a different character (1Ch). the message also misses the CRC character after ETX. The best way of communicating with the terminal first is obtaining the manual for the POS communication protocol you are trying to use from the device manufacturer or from the vendor. It also helps if you detail what you are trying to achieve with the POS device...Download software, use the ECR functionality,etc.
来源:https://stackoverflow.com/questions/30023721/communicating-with-serial-port-verifone-vx520