B
b.pruitt
Hello All,
Need a little help with a TCPClient. I am converting a VB6 app to VB
2005 and can't get the same data back from the device I am connected
to.
A little background. I have an Intermec 3400e printer that I want to
upload the label formats from.
My VB6 code is as follows ....
Private Sub ws_DataArrival(ByVal bytesTotal As Long)
Dim vtData As String
ws.GetData vtData, vbString
Dim IPL As New IPLCommandReference 'Just a class I created to
convert ascii control characters.
txtReceive.Text = txtReceive.Text & IPL.Interpreter.Decode(vtData)
End Sub
I get the following results....
<STX>R;<ESC>C<ESC>P;<ETX>
<STX>E2;A2, ;<ETX>
<STX>L39;D0;<ETX>
<STX>W000, ;o00010,00006;f0;h0342;l0142;w0001;<ETX>
<STX>D39;H001, ;o00139,00027;f3;k010;c25,0;b000;r0;d3,Duff
Beer Rules;<ETX>
<STX>R<ETX>
Now with VB 2005
Public Sub ReceiveMessage(ByVal ar As IAsyncResult)
Try
Dim bytesRead As Integer
bytesRead = client.GetStream.EndRead(ar)
If bytesRead < 1 Then
Exit Sub
Else
Dim para() As Object = _
{System.Text.Encoding.ASCII.GetString( _
data, 0, bytesRead)}
Me.Invoke(New delUpdateHistory( _
AddressOf Me.UpdateHistory), para)
End If
client.GetStream.BeginRead( _
data, 0, CInt(client.ReceiveBufferSize), _
AddressOf ReceiveMessage, Nothing)
Catch ex As Exception
End Try
End Sub
I get the following...
<STX>R;<ESC>C<ESC>P;<ETX>
<STX>E2;A2, ;<ETX>
<STX>L39;D0;<ETX>
<STX>W000, ;o00010,00006;f0;h0342;l0142;w0001;<ETX>
<STX>D39;H001, ;o00139,000006;f0;h0342;l0142;w0001;<ETX>
<STX>D39;H001, ;o00139,00027;f342;l0142;w0001;<ETX>
<STX>D39;H001, ;o00139,00027;f3;k010;c25,39;H001, ;o00139,00027;f3;k010;c25,0;b000;r0;d3,Duff
Be01;<ETX>
<STX>D39;H001, ;o00139,00027;f3;k010;c25,0;b000;r0;d39,00027;f3;k010;c25,0;b000;r0;d3,Duff
Beer, oops, Rules;<ETX>
<STX>R<ETX>
I can not figure out why I get the extra lines of data. The Intermec
printer sends the data in 64 byte chunks, don't know if that helps.
I have connected to the same printer using HyperTerminal(Winsock) and
get the same results as in VB 2005.
This is my first attempt at network programming in .Net, so be gentle.
All of my testing has been done on Windows XP.
HyperTerminal, VB6, and VB2005 all running on my PC using the same
network adapter and printer connection.
Any help would be greatly appreciated.
Need a little help with a TCPClient. I am converting a VB6 app to VB
2005 and can't get the same data back from the device I am connected
to.
A little background. I have an Intermec 3400e printer that I want to
upload the label formats from.
My VB6 code is as follows ....
Private Sub ws_DataArrival(ByVal bytesTotal As Long)
Dim vtData As String
ws.GetData vtData, vbString
Dim IPL As New IPLCommandReference 'Just a class I created to
convert ascii control characters.
txtReceive.Text = txtReceive.Text & IPL.Interpreter.Decode(vtData)
End Sub
I get the following results....
<STX>R;<ESC>C<ESC>P;<ETX>
<STX>E2;A2, ;<ETX>
<STX>L39;D0;<ETX>
<STX>W000, ;o00010,00006;f0;h0342;l0142;w0001;<ETX>
<STX>D39;H001, ;o00139,00027;f3;k010;c25,0;b000;r0;d3,Duff
Beer Rules;<ETX>
<STX>R<ETX>
Now with VB 2005
Public Sub ReceiveMessage(ByVal ar As IAsyncResult)
Try
Dim bytesRead As Integer
bytesRead = client.GetStream.EndRead(ar)
If bytesRead < 1 Then
Exit Sub
Else
Dim para() As Object = _
{System.Text.Encoding.ASCII.GetString( _
data, 0, bytesRead)}
Me.Invoke(New delUpdateHistory( _
AddressOf Me.UpdateHistory), para)
End If
client.GetStream.BeginRead( _
data, 0, CInt(client.ReceiveBufferSize), _
AddressOf ReceiveMessage, Nothing)
Catch ex As Exception
End Try
End Sub
I get the following...
<STX>R;<ESC>C<ESC>P;<ETX>
<STX>E2;A2, ;<ETX>
<STX>L39;D0;<ETX>
<STX>W000, ;o00010,00006;f0;h0342;l0142;w0001;<ETX>
<STX>D39;H001, ;o00139,000006;f0;h0342;l0142;w0001;<ETX>
<STX>D39;H001, ;o00139,00027;f342;l0142;w0001;<ETX>
<STX>D39;H001, ;o00139,00027;f3;k010;c25,39;H001, ;o00139,00027;f3;k010;c25,0;b000;r0;d3,Duff
Be01;<ETX>
<STX>D39;H001, ;o00139,00027;f3;k010;c25,0;b000;r0;d39,00027;f3;k010;c25,0;b000;r0;d3,Duff
Beer, oops, Rules;<ETX>
<STX>R<ETX>
I can not figure out why I get the extra lines of data. The Intermec
printer sends the data in 64 byte chunks, don't know if that helps.
I have connected to the same printer using HyperTerminal(Winsock) and
get the same results as in VB 2005.
This is my first attempt at network programming in .Net, so be gentle.
All of my testing has been done on Windows XP.
HyperTerminal, VB6, and VB2005 all running on my PC using the same
network adapter and printer connection.
Any help would be greatly appreciated.