As a hobby, I'm interested in programming an LED sign connected to Ethernet to scroll through messages on the screen. But I have problems sending UDP sender to VB.NET (I am using 2008 now).
Now the mark is good enough to the specification for programming for him .
But an example of a line for sending it (page 3):
<0x01>Z30<0x02>AA<0x06><0x1B>0b<0x1C>1<0x1A>1This message will show up on the screen<0x04>
With codes such as <0x01> representing a hexadecimal character.
Now, to send this to the character, I need to use UDP . However, in the examples that I encoded everything as ASCII before sending, like this one (from UDP: the client sends packets and receives packets from the server ):
Imports System.Threading
Imports System.Net.Sockets
Imports System.IO
Imports System.Net
Public Class MainClass
Shared Dim client As UdpClient
Shared Dim receivePoint As IPEndPoint
Public Shared Sub Main()
receivePoint = New IPEndPoint(New IPAddress(0), 0)
client = New UdpClient(8888)
Dim thread As Thread = New Thread(New ThreadStart(AddressOf WaitForPackets))
thread.Start()
Dim packet As String = "client"
Console.WriteLine("Sending packet containing: ")
'
' Note the following line below, would appear to be my problem.
'
Dim data As Byte() = System.Text.Encoding.ASCII.GetBytes(packet)
client.Send(data, data.Length, "localhost", 5000)
Console.WriteLine("Packet sent")
End Sub
Shared Public Sub WaitForPackets()
While True
Dim data As Byte() = client.Receive(receivePoint)
Console.WriteLine("Packet received:" & _
vbCrLf & "Length: " & data.Length & vbCrLf & _
System.Text.Encoding.ASCII.GetString(data))
End While
End Sub ' WaitForPackets
End Class
VB.NET, , & H1A - , < 0x1A > .
, ?
Grant ( ), Hamish Smith ( ) Hafthor (hardcoded chr() ) . , . , ââ, , "" , , .
. - ( ): http://www.brettjamesonline.com/misc/forums/other/working.raw : http://www.brettjamesonline.com/misc/forums/other/failed.raw. , , : http://www.brettjamesonline.com/misc/forums/other/snapshotcoding.png.
:
container = &H1 & "Z" & &H30 & &H2 & "temp.nrg" & &H1C & "1Something" & &H4
' This did not appear to work neither
'container = Chr(&H1) & "Z" & Chr(&H30) & Chr(&H2) & Chr(&H1C) & "1Something" & Chr(&H4)
'<0x01>Z00<0x02>FILENAME<0x1C>1Test to display<0x04> <- the "official" spec to send
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(container)
( : http://pastebin.com/f44417743.)