I will than strings contain control characters converted to hexadecimal ASCII said
02 30 30 to 35 34 31 20 20 20 03 31 33 0 d 0 a in serial assistants used in hexadecimal to send, instrument response success,
So the question comes, if I am in ASCII way how do you say?
I written in vb.net program, a serial port serialport controls used in the write () method sends a string is no response, is there something I need in the heart of the program than string into hexadecimal byte array, how to turn?
Bosses, please feel free to comment!
CodePudding user response:
The integer number, a string into a Byte [] methods:BitConverter. GetByte (data or string); Here is the default Unicode string,
//gb2312 encoding is converted into a byte []
System. Text. Encoding. GetEncoding (936). GetBytes (" content ");
CodePudding user response:
Or ask, so I control serialport via a serial port communication, how to send a string of the 14 to equipment (4 control characters, the three blanks) STX + "00541" + "13" + CR + LF + etx,No response code as follows, instrument through a serial port debug tool above, can enter the hexadecimal code communication:
Dim strSendStr string
StrSendStr=CRH (2) & amp; "00541" & amp;" 13 "& amp; VbCr & amp; VbLf
Serialport1. Write (strSendStr) 'sends a string
CodePudding user response:
Serialport1. Write (strSendStr), as a string haven't sent out, because the hair after I receive a variable with the bytes of send buffer area, found or 0, finish the whole operation procedure, is no exception, is this why? There are bosses know?
CodePudding user response: