Testing of the Winsock (ActiveX) with the SX Ethernet Demo Board and VBScripting
Lesson 3 "Changing the SX's Source code."

Okay, we are now into lesson 3 with some more great fun.
Firts of lets locate that part of the code that we were discussing in lesson 2. I usually find it the quickest by using the find feature and then finding UDPAppProcPktIn in the source code. After you have found this source code lets now make some changes to it. I know this seems a bit old school but we all started out with the "HELLO WORLD" string and that is what we are going to send the browser. What is in the Blue is what has already been done from our friends at Ubicom. What I put in red is what we are going to be adding in or changing.
So lets get started.

; ******************************************************************************
UDPAppProcPktIn
; Application Incoming UDP packet handler (Example)
; This function is called whenever an application (matches udpRxDestPortxSB)
; packet is received. The appplication can call NICReadAgain() to extract
; sequentially extract each byte of the field in the UDP packet.
; [UDP API Function]
; INPUT: {udpRxDataLenMSB,udpRxDataLenLSB} = number of bytes in UDP
; {udpRxSrcPortMSB,udpRxSrcPortLSB} = UDP
; OUTPUT: none
; ******************************************************************************


call NICReadAgain_7
and w, #%01000000
xor ra, w ; toggle I/O pins
_bank UDP_BANK
clr udpTxSrcPortMSB
clr udpTxSrcPortLSB

mov udpTxDestPortMSB, udpRxSrcPortMSB
mov udpTxDestPortLSB, udpRxSrcPortLSB

clr udpTxDataLenMSB
mov udpTxDataLenLSB,
#12 ;This is how Many bytes of data to send

call UDPStartPktOut
mov w, #'H'
call NICWriteAgain_7
mov w, #'E'
call NICWriteAgain_7
mov w, #'L'
call NICWriteAgain_7
mov w, #'L' call NICWriteAgain_7
mov w, #'O'
call NICWriteAgain_7
mov w, #' '
call NICWriteAgain_7
mov w, #'W'
call NICWriteAgain_7
mov w, #'O'
call NICWriteAgain_7
mov w, #'R'
call NICWriteAgain_7
mov w, #'L'
call NICWriteAgain_7
mov w, #'D'
call NICWriteAgain_7
mov w, #13 ; LF
call NICWriteAgain_7
Call @UDPEndPktOut



Now that you have made your changes to your SX's source code when you press the button bellow you should now get "HELLO WORLD" displayed in the last text box.

This is the object tag for MSWINSOCK Ver. 6.0 Set up a form here and call it LabelControls, it will have no Action.
Put a textbox with a name of Port on the screen. This is where you will put the port number to communicate at. Default is 1025. SX'S PORT
Put a textbox with a name of Ip on the screen. This is where you will put the SX's ip address. SX'S IP
Put a textbox with a name of Data on the screen. This is where you will put what you want to write to the SX at. Info you want to write to SX 0 to 255.
Put a textbox with a name of Readout on the screen. This is the area wich will tell you what is happening when you press the SendData Button. This info is read from the SX via UDP Protocol.
Put a Button with a name of CmdSend on the screen. This button will send data that is in the Data Textbox to the SX.


Now lets take a closer look at the control.

Sub Sock_DataArrival(ByVal bytesTotal)

Dim New_info
'vbString or vbInteger
Sock.GetData New_info, vbString
'Write info to the READOUT Textbox.
Form1.READOUT.Value = New_info

End Sub

Now you should use vbString for String data and vbInteger for sctrictly integer data.