Testing of the Winsock (ActiveX) with the SX Ethernet Demo Board and VBScripting
Lesson 2 "Understanding the Udp source on the SX"
First lets start by locating the following code in the isx_2_3_5.src code
Written by Wing Poon, Deon Roelofse, Chris Waters . V2.3.5 . 1/9/01 . (C) Scenix, Inc.
; ******************************************************************************
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
clr udpTxDataLenMSB ; send 2 bytes of data
mov udpTxDataLenLSB, #2 ;
call UDPStartPktOut
mov w, ra ; send new port state
call NICWriteAgain_7
mov w, #$00 ; one-byte padding
call NICWriteAgain_7
jmp UDPEndPktOut
Now there is two parts of this code that I want to bring up and after seeing it you might be kicking yourself in the buttock for not noticing it before and putting two and two together like I did.
The first part is the function or subroutine, Wether you are a C or VB programmer, called call NICReadAgain_7. As the Authors state you can call this a few times to read out sequential data.
Anyway the code is using this and anding it in the next line. and w, #%01000000 You may be asking why, well if you look at your schematic in the back of the book at the led it is RA.6 (cled). And with the next line xor ra,w ; toggle I/O pins you are actually toggling the led on and off. Pretty darn slick ain't it.
Now why do you use and 'w with %01000000'? %01000000 is actually Dec value 64. Remember in Lesson 1 that I said that you needed to put a number equal or greater than that of 64 into the info box to send data to the SX to get the led to turn on and off.
The Second part is the function or subroutine called call NICWriteAgain_7. This is a very usefull function like the above and can stream out the udp data. First simply move the data from a register of your choice into w and then call the function. You will be able to capture the data using the Winsock control in Most anytype of Application that you can put an ActiveX Winsock control into. Examples are Java, JavaScript, VB, VBScript, C, and of course Visual C++ or any C++.
In the next lesson we will play with the code and read and write to diffrent locations.
Look at the source code for this page even closer and take a more in depth look at the VBScript. I choose VB script for now because more people understand Basic than that of JavaScript. Not to fret Java Guru's I will in time release code in JavaScript. If you want some good JavaScript now you can check out my bindicator remote display featured on the SXList under http://www.sxlist.com/techref/ubicom/bindicator/index.htm
This was actually my first project with the Sx Ethernet Demo Board
This is the object tag for MSWINSOCK Ver. 6.0Set up a form here and call it LabelControls, it will have no Action.
Go ahead and play around with what you have here. The next lesson will delve deeper into the udp protocol on the Ethernet demo Board with reading info and writing info.
Go ahead and if you have a question drop me a line at the following Address.
This code is free to anyone whom has a need for it.
(C) By: Timothy L. Hosey, Automated Panels. (2001-2002), Engineering, Extension 41367 Email Timothy Hosey