-----Original Message-----
From: Jeremy Severson
Sent: Tuesday, January 27, 2004 1:12 PM
Subject: Technical Notes Addition: Resetting Your Vlinx Ethernet Serial Server Remotely (Visual Basic 6.0 Version)

 

Dear Readers,

            A number of you have read the Technical Notes article on Resetting Your Vlinx Ethernet Serial Server Remotely and requested source code for Microsoft Visual Basic. I have recently investigated this very issue for an upcoming product and have decided to pass this information on in hopes that it may help you out in your applications. Please note that the source is in a very rough state and a polished version will appear in a future Technical Notes article. With the original Technical Notes article as a reference hopefully this will help you out. Note that when I build the command string I place the following things within it:

“Passport Networks Inc.”                        Required

“0331003606” –                                      This is the serial number of my device…will need to be replaced with the serial number of your device

“<00><0B><B4><11><0E><16>”  -         This is the MAC address of my device…will need to be replaced with the MAC address of your device

 

The <00>’s are required padding. In the end you should end up with a 67 byte packet which you can send out into the Ethernet using UDP. Note that for this example I used the Winsock control that shipped with Microsoft Visual Basic 6.0.

 

 

 

SOURCE CODE STARTS HERE----------------------------------------------------

 

 

Code to initialize the Microsoft winsock activeX control

WinsockControl.Close

WinsockControl.RemoteHost = "255.255.255.255"

WinsockControl.RemotePort = 8888

WinsockControl.LocalPort = 4000

WinsockControl.Protocol = sckUDPProtocol

WinsockControl.Bind 4000

 

Build command string

returnValue = "Passport Networks Inc." & HexStringToRawDataString("<00><00>") & "0331003606" & HexStringToRawDataString("<00><00><00><00><00><00>") & HexStringToRawDataString("<00><0B><B4><11><0E><16>") & "reset" & HexStringToRawDataString("<00><00><00><00><00><00><00><00>")

 

Send Message to reset ESP Device

WinsockControl.SendData returnValue

 

'*****************************************************************************

'Function: HexStringToRawDataString()

'Passed a formatted hex string in the format of <01><02><0A> .... and returns a string containing the real data

'*****************************************************************************

Public Function HexStringToRawDataString(HexString As String) As String

Dim returnValue As String

Dim tempHolder() As Byte

Dim counter As Integer

Dim BufferPointer As Integer

Dim tempValue As Byte

Dim jumpAmount As Integer

 

BufferPointer = 0

counter = 1

 

If (Mid(HexString, counter, 1) = "<") Then

   jumpAmount = 4

Else

   jumpAmount = 2

End If

 

counter = 2

Do While (counter < Len(HexString))

   tempValue = Val("&H" & Mid(HexString, counter, 2))

   returnValue = returnValue & Chr(tempValue)

   BufferPointer = BufferPointer + 1

   counter = counter + jumpAmount

Loop

HexStringToRawDataString = returnValue

End Function

 

 

SOURCE CODE ENDS HERE----------------------------------------------------

 

Jeremy Severson

Software Engineer

 

B&B Electronics

707 Dayton Rd

Ottawa IL, 61350