Sending ascii extended characters via serial port [modified]
-
Hello, I am making an application which can control a pabx (telephone switch). I connect my pc and the pabx via com port. For the connection setup i have to send some characterlines to the pabx. Sending normal ascii characters works fine. I use: SerialPort.WriteLine(Chr(&H10) & Chr(&H2) & Chr(&H20) & Chr(&H2) & Chr(&H0) & Chr(&H10) & Chr(&H3)) However, i have to send also hex97 (for example). Is there someone who can give me some information. I guess i have to change the character set? But how? Regards, Bas
modified on Saturday, April 5, 2008 6:12 AM
-
Hello, I am making an application which can control a pabx (telephone switch). I connect my pc and the pabx via com port. For the connection setup i have to send some characterlines to the pabx. Sending normal ascii characters works fine. I use: SerialPort.WriteLine(Chr(&H10) & Chr(&H2) & Chr(&H20) & Chr(&H2) & Chr(&H0) & Chr(&H10) & Chr(&H3)) However, i have to send also hex97 (for example). Is there someone who can give me some information. I guess i have to change the character set? But how? Regards, Bas
modified on Saturday, April 5, 2008 6:12 AM
Send Ascii value insted if Hexcode example i want to sent " charachter SerialPort.WriteLine(Chr(34))
Rajesh B --> A Poor Workman Blames His Tools <--
-
Send Ascii value insted if Hexcode example i want to sent " charachter SerialPort.WriteLine(Chr(34))
Rajesh B --> A Poor Workman Blames His Tools <--
Hello Rajesh, Thanks for your answer. I tried but when i send the character instead of Hex then i stil have to use an other character set, because hex97 = character 151. Standard ascii set starts at 0 and ends at 127. Extended ascii character set starts at 128 and ends at 255. As i have to send hex97 or character 151 i guess i have to change the character set but i do not know how and to which character set. Regards, Bas
-
Hello Rajesh, Thanks for your answer. I tried but when i send the character instead of Hex then i stil have to use an other character set, because hex97 = character 151. Standard ascii set starts at 0 and ends at 127. Extended ascii character set starts at 128 and ends at 255. As i have to send hex97 or character 151 i guess i have to change the character set but i do not know how and to which character set. Regards, Bas
try with ChrW() insted of Chr() reply me...
Rajesh B --> A Poor Workman Blames His Tools <--
-
try with ChrW() insted of Chr() reply me...
Rajesh B --> A Poor Workman Blames His Tools <--
-
first check u r encoding of serial port set below encoding for UTF-8 support SerialPort1.Encoding = System.Text.Encoding.GetEncoding(1252) after try this code Dim mybyte As Byte = 150 serialport.write(mybyte ) i think it will work
Rajesh B --> A Poor Workman Blames His Tools <--
-
first check u r encoding of serial port set below encoding for UTF-8 support SerialPort1.Encoding = System.Text.Encoding.GetEncoding(1252) after try this code Dim mybyte As Byte = 150 serialport.write(mybyte ) i think it will work
Rajesh B --> A Poor Workman Blames His Tools <--
-
Hello Rajesh, Thanks a lot, this works fine. I have been working for at least two weeks on this problem and now within two hours you solved my problem. Regards, Bas
Welcome :cool:
Rajesh B --> A Poor Workman Blames His Tools <--
-
Hello, I am making an application which can control a pabx (telephone switch). I connect my pc and the pabx via com port. For the connection setup i have to send some characterlines to the pabx. Sending normal ascii characters works fine. I use: SerialPort.WriteLine(Chr(&H10) & Chr(&H2) & Chr(&H20) & Chr(&H2) & Chr(&H0) & Chr(&H10) & Chr(&H3)) However, i have to send also hex97 (for example). Is there someone who can give me some information. I guess i have to change the character set? But how? Regards, Bas
modified on Saturday, April 5, 2008 6:12 AM
keninfo wrote:
SerialPort.WriteLine(Chr(&H10) & Chr(&H2) & Chr(&H20) & Chr(&H2) & Chr(&H0) & Chr(&H10) & Chr(&H3)) However, i have to send also hex97 (for example).
So what's wrong with writing
Chr(&h97)
??A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Hello, I am making an application which can control a pabx (telephone switch). I connect my pc and the pabx via com port. For the connection setup i have to send some characterlines to the pabx. Sending normal ascii characters works fine. I use: SerialPort.WriteLine(Chr(&H10) & Chr(&H2) & Chr(&H20) & Chr(&H2) & Chr(&H0) & Chr(&H10) & Chr(&H3)) However, i have to send also hex97 (for example). Is there someone who can give me some information. I guess i have to change the character set? But how? Regards, Bas
modified on Saturday, April 5, 2008 6:12 AM
Hi, if you need to send special byte values over SerialPort, forget about text, strings and encodings, and use SerialPort.Write, which works with byte arrays, no encoding, no translation. What you get is what you ordered. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.