Set Serial Port Encoding

  1. Set Serial Port Encoding Center

Everyone,I'm making an app that connect to a serial port device, The Newbridge 36110 MainStreet, I am able to login type in a command like 'CFG' then the terminal would prompt me with CFGbut when I send a command like 'FEP 01,X25' it gives me an error syntax error and it displays only 'FEP' then when I send that command again it would display 'FEP,X' then again would display 'FEP 0' it like can only process the 1st syntax not after the space or byte by byte not sure. By the way the is an ascii box code.

Set Serial Port Encoding

Please help me on this guys. Actual code below.Dim WithEvents SP As New IO.Ports.SerialPortPrivate Sub frmMainLoad( ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadSP.PortName = ' COM1'SP.BaudRate = 9600SP.Parity = IO.Ports.Parity.NoneSP.StopBits = IO.Ports.StopBits.OneSP.DataBits = 8SP.DtrEnable = TrueSP.RtsEnable = TrueSP.Encoding = System.Text.Encoding.ASCIISP.Handshake = IO.Ports.Handshake.NoneEnd Sub Private Sub btnSendClick( ByVal sender As System.

Object, ByVal e As System.EventArgs) Handles btnSend.ClickTrySP.Write(txtCommand.Text & Chr( 13))txtCommand.Text = String.EmptyCatch ex As ExceptionMsgBox(ex.ToString)End Try End Sub Private Sub btnFEPClick( ByVal sender As System. Object, ByVal e As System.EventArgs) Handles btnFEP.Click' Send A FEP 01,X25 Command Dim str As String = ' FEP 01,X25'SP.Write(str & Chr( 13))End SubI created the btnFEP to send the command automatically, the command can also be sent from btnSEND where the txtCommand is where typed in the syntax. When answering a question please:. Read the question carefully. Understand that English isn't everyone's first language so be lenient of badspelling and grammar.

Port

If a question is poorly phrased then either ask for clarification, ignore it, oredit the question and fix the problem. Insults are not welcome. Don't tell someone to read the manual. Chances are they have and don't get it.Provide an answer or move on to the next question.Let's work to help developers, not make them feel stupid.

Set Serial Port Encoding

Hello,I am trying to send hex or characters to serial port, and it work's fine from 0 to 127 (&H7F).From 128 (&H80) to 255 (&HFF) the output is always 63 (3F) ( '?' It seems that can not handle extended ASCII characters.How can i overcame this situation?Here's the code i am using:Private Sub Button1Click(sender As Object, e As EventArgs) Handles Button1.ClickDim a, a1, a2, a3, a4, a5 As StringSerialPort1.BaudRate = 9600SerialPort1.DataBits = 8SerialPort1.Parity = IO.Ports.Parity.NoneSerialPort1.StopBits = IO.Ports.StopBits.TwoSerialPort1.Opena1 = TextBox1.Texta2 = TextBox2.Texta3 = TextBox3.Texta4 = TextBox4.Texta5 = TextBox5.Texta = Chr(a1) + Chr(a2) + Chr(a3) + Chr(a4) + Chr(a5)SerialPort1.Write(a)SerialPort1.CloseEnd SubThanks in advance. I am trying to send hex or characters to serial port, and it work's fine from 0 to 127 (&H7F).From 128 (&H80) to 255 (&HFF) the output is always 63 (3F) ( '?'

Set Serial Port Encoding Center

It seems that can not handle extended ASCII characters.Don't use the string writing functions unless you are quite sure that all the data is ASCII. Even then, it is often easier to work in bytes instead of characters. Also, the string concatenation character is &, not +. Byte writingwould look like this: Dim a(4) As Bytea(0) = AscW(TextBox1.Text)a(1) = AscW(TextBox2.Text)a(2) = AscW(TextBox3.Text)a(3) = AscW(TextBox4.Text)a(4) = AscW(TextBox5.Text)serialport1.Write(a, 0, 5)However, as you refer to values greater than 127, I'm not sure that Chr or Asc is what you mean - perhaps it should beCInt, depending on what is being entered in those text boxes.