Hello everyone,
New forum member here. had this weird problem, and can't seem to find the solution anywhere! I am using VB .net 2005 on an XP based laptop. I have this controller-based hardware connected to the serial port of my laptop. My serial port is only using 3 pins, transmit, receive, and signal ground. I am transmitting hexadecimal bytes contained in an array to the hardware and expects to get response from the hardware.
If let's say I transmit 15, 4, 17, 6, (in hexadecimal) sequentially; the hardware will execute 'system reset'. I managed to do this just fine by using;
the hardware DID reset on this event , but if I want to monitor the data sent through serial port by putting the transmitted data in a textbox as below;
instead of the "15, 4, 17, 6" that I transmitted, the textbox just displays 4 'boxes'! i tried editing the transmitted data by deleting the 'char' typecast from the above code, turning it into;
by using this, i can display the transmitted data in textbox very well, but the hardware did not reset . why is this so? i want the user to be able to display the transmitted text correctly, how can i do this?
here is my complete code. it is very short, resides on only 1 form that has one textbox to display the transmitted data, and one button to trigger the transmission of data to serial port. please advise, thank you!
New forum member here. had this weird problem, and can't seem to find the solution anywhere! I am using VB .net 2005 on an XP based laptop. I have this controller-based hardware connected to the serial port of my laptop. My serial port is only using 3 pins, transmit, receive, and signal ground. I am transmitting hexadecimal bytes contained in an array to the hardware and expects to get response from the hardware.
If let's say I transmit 15, 4, 17, 6, (in hexadecimal) sequentially; the hardware will execute 'system reset'. I managed to do this just fine by using;
VB.NET:
TxBuffer = New String() {Chr(&H15), Chr(&H4), Chr(&H17), Chr(&H6)}
the hardware DID reset on this event , but if I want to monitor the data sent through serial port by putting the transmitted data in a textbox as below;
VB.NET:
TextBox1.Text = TextBox1.Text & " " & TxBuffer(i)
instead of the "15, 4, 17, 6" that I transmitted, the textbox just displays 4 'boxes'! i tried editing the transmitted data by deleting the 'char' typecast from the above code, turning it into;
VB.NET:
TxBuffer = New String() {&H15, &H4, &H17, &H6}
by using this, i can display the transmitted data in textbox very well, but the hardware did not reset . why is this so? i want the user to be able to display the transmitted text correctly, how can i do this?
here is my complete code. it is very short, resides on only 1 form that has one textbox to display the transmitted data, and one button to trigger the transmission of data to serial port. please advise, thank you!
VB.NET:
Public Class Form1
Dim TxBuffer() As String 'Telegram message to send
Dim TxBufferSize As Integer 'Size of dynamic array
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SerialPort1.Open()
End Sub
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
SerialPort1.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TxBuffer = New String() {Chr(&H15), Chr(&H4), Chr(&H17), Chr(&H6)} 'reset OK, but display squares
'TxBuffer = New String() {&H15, &H4, &H17, &H6} 'reset not OK , but display OK
TxBufferSize = UBound(TxBuffer) 'Get array size
TransmitData(TxBuffer,TxBufferSize)
End Sub
End Class
Last edited: