1 |
''************************************** |
= |
1 |
''************************************** |
2 |
'' |
|
2 |
'' |
3 |
'' Brilldea W5100 TCP Server Echo Demo indirect Ver. 00.1 |
<> |
3 |
'' Brilldea W5100 Web Page Demo indirect Ver. 00.1 |
4 |
'' |
= |
4 |
'' |
5 |
'' Timothy D. Swieter, P.E. |
|
5 |
'' Timothy D. Swieter, P.E. |
6 |
'' Brilldea - purveyor of prototyping goods |
|
6 |
'' Brilldea - purveyor of prototyping goods |
7 |
'' www.brilldea.com |
|
7 |
'' www.brilldea.com |
8 |
'' |
|
8 |
'' |
9 |
'' Copyright (c) 2010 Timothy D. Swieter, P.E. |
|
9 |
'' Copyright (c) 2010 Timothy D. Swieter, P.E. |
10 |
'' See end of file for terms of use and MIT License |
|
10 |
'' See end of file for terms of use and MIT License |
11 |
'' |
|
11 |
'' |
12 |
'' Updated: June 26, 2010 |
|
12 |
'' Updated: June 26, 2010 |
13 |
'' |
|
13 |
'' |
14 |
''Description: |
|
14 |
''Description: |
15 |
'' |
|
15 |
'' |
16 |
'' This is a TCP server echoing demo driver for the W5100. This program will |
<> |
16 |
'' This is a demo of serving a web page using the W5100 IC and a Indirect Driver program in the Propeller. |
17 |
'' use the Indirect driver. |
|
|
|
18 |
'' |
= |
17 |
'' |
19 |
'' To use this program you will need a terminal program, perhaps the Parallax Serial Terminal. |
+- |
|
|
20 |
'' You will also need a tool to establish TCP/sockets and send pacakets, we used TCP Test Tool 2.3 by Simple Com Tools (wwww.simplecomtools.com) |
|
|
|
21 |
'' |
|
|
|
22 |
'' Before using this program review the network settings listed into the program (mac ID, gateway, subnet, IP adresses) |
|
|
|
23 |
'' |
|
|
|
24 |
'' Have the terminal program open and ready, then load this program to the device or reset the device. |
|
|
|
25 |
'' Status of the W5100 initializing will be displayed. Eventually the program will |
|
|
|
26 |
'' initialize a TCP server waiting for connection. The user (you) should establish a connection and send TCP data |
|
|
|
27 |
'' packets to the IP address/socket that the device was initialized with. The device will |
|
|
|
28 |
'' then acknowledge receipt of the packet and send it back to the user. |
|
|
|
29 |
'' |
|
|
|
30 |
''Reference: |
= |
18 |
''Reference: |
31 |
'' |
|
19 |
'' |
32 |
''To do: |
|
20 |
''To do: |
33 |
'' |
|
21 |
'' |
34 |
''Revision Notes: |
|
22 |
''Revision Notes: |
35 |
'' 0.1 Start of design based on UDP demo |
<> |
23 |
'' 0.1 Start of design |
|
|
|
24 |
'' 20101119 Michael O'Brien |
|
|
|
25 |
'' Modified for AJAX proof of concept |
36 |
'' |
= |
26 |
'' |
37 |
''************************************** |
|
27 |
''************************************** |
38 |
CON 'Constants to be located here |
|
28 |
CON 'Constants to be located here |
39 |
'*************************************** |
|
29 |
'*************************************** |
40 |
'*************************************** |
|
30 |
'*************************************** |
41 |
' Firmware Version |
|
31 |
' Firmware Version |
42 |
'*************************************** |
|
32 |
'*************************************** |
43 |
FWmajor = 0 |
|
33 |
FWmajor = 0 |
44 |
FWminor = 1 |
|
34 |
FWminor = 1 |
45 |
|
|
35 |
|
46 |
DAT |
|
36 |
DAT |
47 |
TxtFWdate byte "June 26, 2010",0 |
|
37 |
TxtFWdate byte "June 26, 2010",0 |
48 |
|
|
38 |
|
49 |
CON |
|
39 |
CON |
50 |
|
|
40 |
|
51 |
'*************************************** |
|
41 |
'*************************************** |
52 |
' Processor Settings |
|
42 |
' Processor Settings |
53 |
'*************************************** |
|
43 |
'*************************************** |
54 |
_clkmode = xtal1 + pll16x 'Use the PLL to multiple the external clock by 16 |
|
44 |
_clkmode = xtal1 + pll16x 'Use the PLL to multiple the external clock by 16 |
55 |
_xinfreq = 5_000_000 'An external clock of 5MHz. is used (80MHz. operation) |
|
45 |
_xinfreq = 5_000_000 'An external clock of 5MHz. is used (80MHz. operation) |
56 |
|
|
46 |
|
57 |
'*************************************** |
|
47 |
'*************************************** |
58 |
' System Definitions |
|
48 |
' System Definitions |
59 |
'*************************************** |
|
49 |
'*************************************** |
60 |
|
|
50 |
|
61 |
_OUTPUT = 1 'Sets pin to output in DIRA register |
|
51 |
_OUTPUT = 1 'Sets pin to output in DIRA register |
62 |
_INPUT = 0 'Sets pin to input in DIRA register |
|
52 |
_INPUT = 0 'Sets pin to input in DIRA register |
63 |
_HIGH = 1 'High=ON=1=3.3V DC |
|
53 |
_HIGH = 1 'High=ON=1=3.3V DC |
64 |
_ON = 1 |
|
54 |
_ON = 1 |
65 |
_LOW = 0 'Low=OFF=0=0V DC |
|
55 |
_LOW = 0 'Low=OFF=0=0V DC |
66 |
_OFF = 0 |
|
56 |
_OFF = 0 |
67 |
_ENABLE = 1 'Enable (turn on) function/mode |
|
57 |
_ENABLE = 1 'Enable (turn on) function/mode |
68 |
_DISABLE = 0 'Disable (turn off) function/mode |
|
58 |
_DISABLE = 0 'Disable (turn off) function/mode |
69 |
|
|
59 |
|
70 |
{ |
|
60 |
{ |
71 |
'*************************************** |
|
61 |
'*************************************** |
72 |
' I/O Definitions of PropNET Module |
|
62 |
' I/O Definitions of PropNET Module |
73 |
'*************************************** |
|
63 |
'*************************************** |
74 |
|
|
64 |
|
75 |
'~~~~Propeller Based I/O~~~~ |
|
65 |
'~~~~Propeller Based I/O~~~~ |
76 |
'W5100 Module Interface |
|
66 |
'W5100 Module Interface |
77 |
_WIZ_data0 = 0 'SPI Mode = MISO, Indirect Mode = data bit 0. |
|
67 |
_WIZ_data0 = 0 'SPI Mode = MISO, Indirect Mode = data bit 0. |
78 |
_WIZ_miso = 0 |
|
68 |
_WIZ_miso = 0 |
79 |
_WIZ_data1 = 1 'SPI Mode = MOSI, Indirect Mode = data bit 1. |
|
69 |
_WIZ_data1 = 1 'SPI Mode = MOSI, Indirect Mode = data bit 1. |
80 |
_WIZ_mosi = 1 |
|
70 |
_WIZ_mosi = 1 |
81 |
_WIZ_data2 = 2 'SPI Mode unused, Indirect Mode = data bit 2 dependent on solder jumper on board. |
|
71 |
_WIZ_data2 = 2 'SPI Mode unused, Indirect Mode = data bit 2 dependent on solder jumper on board. |
82 |
_WIZ_data3 = 3 'SPI Mode = SCLK, Indirect Mode = data bit 3. |
|
72 |
_WIZ_data3 = 3 'SPI Mode = SCLK, Indirect Mode = data bit 3. |
83 |
_WIZ_sclk = 3 |
|
73 |
_WIZ_sclk = 3 |
84 |
_WIZ_data4 = 4 'SPI Mode unused, Indirect Mode = data bit 4 dependent on solder jumper on board. |
|
74 |
_WIZ_data4 = 4 'SPI Mode unused, Indirect Mode = data bit 4 dependent on solder jumper on board. |
85 |
_WIZ_data5 = 5 'SPI Mode unused, Indirect Mode = data bit 5 dependent on solder jumper on board. |
|
75 |
_WIZ_data5 = 5 'SPI Mode unused, Indirect Mode = data bit 5 dependent on solder jumper on board. |
86 |
_WIZ_data6 = 6 'SPI Mode unused, Indirect Mode = data bit 6 dependent on solder jumper on board. |
|
76 |
_WIZ_data6 = 6 'SPI Mode unused, Indirect Mode = data bit 6 dependent on solder jumper on board. |
87 |
_WIZ_data7 = 7 'SPI Mode unused, Indirect Mode = data bit 7 dependent on solder jumper on board. |
|
77 |
_WIZ_data7 = 7 'SPI Mode unused, Indirect Mode = data bit 7 dependent on solder jumper on board. |
88 |
_WIZ_addr0 = 8 'SPI Mode unused, Indirect Mode = address bit 0 dependent on solder jumper on board. |
|
78 |
_WIZ_addr0 = 8 'SPI Mode unused, Indirect Mode = address bit 0 dependent on solder jumper on board. |
89 |
_WIZ_addr1 = 9 'SPI Mode unused, Indirect Mode = address bit 1 dependent on solder jumper on board. |
|
79 |
_WIZ_addr1 = 9 'SPI Mode unused, Indirect Mode = address bit 1 dependent on solder jumper on board. |
90 |
_WIZ_wr = 10 'SPI Mode unused, Indirect Mode = /write dependent on solder jumper on board. |
|
80 |
_WIZ_wr = 10 'SPI Mode unused, Indirect Mode = /write dependent on solder jumper on board. |
91 |
_WIZ_rd = 11 'SPI Mode unused, Indirect Mode = /read dependent on solder jumper on board. |
|
81 |
_WIZ_rd = 11 'SPI Mode unused, Indirect Mode = /read dependent on solder jumper on board. |
92 |
_WIZ_cs = 12 'SPI Mode unused, Indirect Mode = /chip select dependent on solder jumper on board. |
|
82 |
_WIZ_cs = 12 'SPI Mode unused, Indirect Mode = /chip select dependent on solder jumper on board. |
93 |
_WIZ_int = 13 'W5100 /interrupt dependent on solder jumper on board. Shared with _OW. |
|
83 |
_WIZ_int = 13 'W5100 /interrupt dependent on solder jumper on board. Shared with _OW. |
94 |
_WIZ_rst = 14 'W5100 chip reset. |
|
84 |
_WIZ_rst = 14 'W5100 chip reset. |
95 |
_WIZ_scs = 15 'SPI Mode SPI Slave Select, Indirect Mode unused dependent on solder jumper on board. |
|
85 |
_WIZ_scs = 15 'SPI Mode SPI Slave Select, Indirect Mode unused dependent on solder jumper on board. |
96 |
|
|
86 |
|
97 |
'I2C Interface |
|
87 |
'I2C Interface |
98 |
_I2C_scl = 28 'Output for the I2C serial clock |
|
88 |
_I2C_scl = 28 'Output for the I2C serial clock |
99 |
_I2C_sda = 29 'Input/output for the I2C serial data |
|
89 |
_I2C_sda = 29 'Input/output for the I2C serial data |
100 |
|
|
90 |
|
101 |
'Serial/Programming Interface (via Prop Plug Header) |
|
91 |
'Serial/Programming Interface (via Prop Plug Header) |
102 |
_SERIAL_tx = 30 'Output for sending misc. serial communications via a Prop Plug |
|
92 |
_SERIAL_tx = 30 'Output for sending misc. serial communications via a Prop Plug |
103 |
_SERIAL_rx = 31 'Input for receiving misc. serial communications via a Prop Plug |
|
93 |
_SERIAL_rx = 31 'Input for receiving misc. serial communications via a Prop Plug |
104 |
} |
|
94 |
} |
105 |
'*************************************** |
|
95 |
'*************************************** |
106 |
' I/O Definitions of Spinneret Web Server Module |
|
96 |
' I/O Definitions of Spinneret Web Server Module |
107 |
'*************************************** |
|
97 |
'*************************************** |
108 |
|
|
98 |
|
109 |
'~~~~Propeller Based I/O~~~~ |
|
99 |
'~~~~Propeller Based I/O~~~~ |
110 |
'W5100 Module Interface |
|
100 |
'W5100 Module Interface |
111 |
_WIZ_data0 = 0 'SPI Mode = MISO, Indirect Mode = data bit 0. |
|
101 |
_WIZ_data0 = 0 'SPI Mode = MISO, Indirect Mode = data bit 0. |
112 |
_WIZ_miso = 0 |
|
102 |
_WIZ_miso = 0 |
113 |
_WIZ_data1 = 1 'SPI Mode = MOSI, Indirect Mode = data bit 1. |
|
103 |
_WIZ_data1 = 1 'SPI Mode = MOSI, Indirect Mode = data bit 1. |
114 |
_WIZ_mosi = 1 |
|
104 |
_WIZ_mosi = 1 |
115 |
_WIZ_data2 = 2 'SPI Mode SPI Slave Select, Indirect Mode = data bit 2 |
|
105 |
_WIZ_data2 = 2 'SPI Mode SPI Slave Select, Indirect Mode = data bit 2 |
116 |
_WIZ_scs = 2 |
|
106 |
_WIZ_scs = 2 |
117 |
_WIZ_data3 = 3 'SPI Mode = SCLK, Indirect Mode = data bit 3. |
|
107 |
_WIZ_data3 = 3 'SPI Mode = SCLK, Indirect Mode = data bit 3. |
118 |
_WIZ_sclk = 3 |
|
108 |
_WIZ_sclk = 3 |
119 |
_WIZ_data4 = 4 'SPI Mode unused, Indirect Mode = data bit 4 |
|
109 |
_WIZ_data4 = 4 'SPI Mode unused, Indirect Mode = data bit 4 |
120 |
_WIZ_data5 = 5 'SPI Mode unused, Indirect Mode = data bit 5 |
|
110 |
_WIZ_data5 = 5 'SPI Mode unused, Indirect Mode = data bit 5 |
121 |
_WIZ_data6 = 6 'SPI Mode unused, Indirect Mode = data bit 6 |
|
111 |
_WIZ_data6 = 6 'SPI Mode unused, Indirect Mode = data bit 6 |
122 |
_WIZ_data7 = 7 'SPI Mode unused, Indirect Mode = data bit 7 |
|
112 |
_WIZ_data7 = 7 'SPI Mode unused, Indirect Mode = data bit 7 |
123 |
_WIZ_addr0 = 8 'SPI Mode unused, Indirect Mode = address bit 0 |
|
113 |
_WIZ_addr0 = 8 'SPI Mode unused, Indirect Mode = address bit 0 |
124 |
_WIZ_addr1 = 9 'SPI Mode unused, Indirect Mode = address bit 1 |
|
114 |
_WIZ_addr1 = 9 'SPI Mode unused, Indirect Mode = address bit 1 |
125 |
_WIZ_wr = 10 'SPI Mode unused, Indirect Mode = /write |
|
115 |
_WIZ_wr = 10 'SPI Mode unused, Indirect Mode = /write |
126 |
_WIZ_rd = 11 'SPI Mode unused, Indirect Mode = /read |
|
116 |
_WIZ_rd = 11 'SPI Mode unused, Indirect Mode = /read |
127 |
_WIZ_cs = 12 'SPI Mode unused, Indirect Mode = /chip select |
|
117 |
_WIZ_cs = 12 'SPI Mode unused, Indirect Mode = /chip select |
128 |
_WIZ_int = 13 'W5100 /interrupt |
|
118 |
_WIZ_int = 13 'W5100 /interrupt |
129 |
_WIZ_rst = 14 'W5100 chip reset |
|
119 |
_WIZ_rst = 14 'W5100 chip reset |
130 |
_WIZ_sen = 15 'W5100 low = indirect mode, high = SPI mode, floating will = high. |
|
120 |
_WIZ_sen = 15 'W5100 low = indirect mode, high = SPI mode, floating will = high. |
131 |
|
|
121 |
|
132 |
_DAT0 = 16 |
|
122 |
_DAT0 = 16 |
133 |
_DAT1 = 17 |
|
123 |
_DAT1 = 17 |
134 |
_DAT2 = 18 |
|
124 |
_DAT2 = 18 |
135 |
_DAT3 = 19 |
|
125 |
_DAT3 = 19 |
136 |
_CMD = 20 |
|
126 |
_CMD = 20 |
137 |
_SD_CLK = 21 |
|
127 |
_SD_CLK = 21 |
138 |
|
|
128 |
|
139 |
_SIO = 22 |
|
129 |
_SIO = 22 |
140 |
|
|
130 |
|
141 |
_LED = 26 'UI - combo LED and buttuon |
<> |
131 |
_LED = 23 'UI - combo LED and button |
142 |
|
= |
132 |
|
143 |
_AUX0 = 24 'MOBO Interface |
|
133 |
_AUX0 = 24 'MOBO Interface |
144 |
_AUX1 = 25 |
|
134 |
_AUX1 = 25 |
145 |
_AUX2 = 26 |
|
135 |
_AUX2 = 26 |
146 |
_AUX3 = 27 |
|
136 |
_AUX3 = 27 |
147 |
|
|
137 |
|
148 |
'I2C Interface |
|
138 |
'I2C Interface |
149 |
_I2C_scl = 28 'Output for the I2C serial clock |
|
139 |
_I2C_scl = 28 'Output for the I2C serial clock |
150 |
_I2C_sda = 29 'Input/output for the I2C serial data |
|
140 |
_I2C_sda = 29 'Input/output for the I2C serial data |
151 |
|
|
141 |
|
152 |
'Serial/Programming Interface (via Prop Plug Header) |
|
142 |
'Serial/Programming Interface (via Prop Plug Header) |
153 |
_SERIAL_tx = 30 'Output for sending misc. serial communications via a Prop Plug |
|
143 |
_SERIAL_tx = 30 'Output for sending misc. serial communications via a Prop Plug |
154 |
_SERIAL_rx = 31 'Input for receiving misc. serial communications via a Prop Plug |
|
144 |
_SERIAL_rx = 31 'Input for receiving misc. serial communications via a Prop Plug |
155 |
|
|
145 |
|
156 |
'*************************************** |
|
146 |
'*************************************** |
157 |
' I2C Definitions |
|
147 |
' I2C Definitions |
158 |
'*************************************** |
|
148 |
'*************************************** |
159 |
_EEPROM0_address = $A0 'Slave address of EEPROM |
|
149 |
_EEPROM0_address = $A0 'Slave address of EEPROM |
160 |
|
|
150 |
|
161 |
'*************************************** |
|
151 |
'*************************************** |
162 |
' Debugging Definitions |
|
152 |
' Debugging Definitions |
163 |
'*************************************** |
|
153 |
'*************************************** |
164 |
|
|
154 |
|
165 |
'*************************************** |
|
155 |
'*************************************** |
166 |
' Misc Definitions |
|
156 |
' Misc Definitions |
167 |
'*************************************** |
|
157 |
'*************************************** |
168 |
|
|
158 |
|
169 |
_bytebuffersize = 2048 |
|
159 |
_bytebuffersize = 2048 |
170 |
|
|
160 |
|
171 |
'************************************** |
|
161 |
'************************************** |
172 |
VAR 'Variables to be located here |
|
162 |
VAR 'Variables to be located here |
173 |
'*************************************** |
|
163 |
'*************************************** |
174 |
|
|
164 |
|
175 |
'Configuration variables for the W5100 |
|
165 |
'Configuration variables for the W5100 |
176 |
byte MAC[6] '6 element array contianing MAC or source hardware address ex. "02:00:00:01:23:45" |
|
166 |
byte MAC[6] '6 element array contianing MAC or source hardware address ex. "02:00:00:01:23:45" |
177 |
byte Gateway[4] '4 element array containing gateway address ex. "192.168.0.1" |
|
167 |
byte Gateway[4] '4 element array containing gateway address ex. "192.168.0.1" |
178 |
byte Subnet[4] '4 element array contianing subnet mask ex. "255.255.255.0" |
|
168 |
byte Subnet[4] '4 element array contianing subnet mask ex. "255.255.255.0" |
179 |
byte IP[4] '4 element array containing IP address ex. "192.168.0.13" |
|
169 |
byte IP[4] '4 element array containing IP address ex. "192.168.0.13" |
180 |
|
|
170 |
|
181 |
'verify variables for the W5100 |
|
171 |
'verify variables for the W5100 |
182 |
byte vMAC[6] '6 element array contianing MAC or source hardware address ex. "02:00:00:01:23:45" |
|
172 |
byte vMAC[6] '6 element array contianing MAC or source hardware address ex. "02:00:00:01:23:45" |
183 |
byte vGateway[4] '4 element array containing gateway address ex. "192.168.0.1" |
|
173 |
byte vGateway[4] '4 element array containing gateway address ex. "192.168.0.1" |
184 |
byte vSubnet[4] '4 element array contianing subnet mask ex. "255.255.255.0" |
|
174 |
byte vSubnet[4] '4 element array contianing subnet mask ex. "255.255.255.0" |
185 |
byte vIP[4] '4 element array containing IP address ex. "192.168.0.13" |
|
175 |
byte vIP[4] '4 element array containing IP address ex. "192.168.0.13" |
186 |
|
|
176 |
|
187 |
long socket '1 element for the socket number |
<> |
177 |
long localSocket '1 element for the socket number |
188 |
|
= |
178 |
|
189 |
'Variables to info for where to return the data to |
|
179 |
'Variables to info for where to return the data to |
190 |
byte destIP[4] '4 element array containing IP address ex. "192.168.0.16" |
|
180 |
byte destIP[4] '4 element array containing IP address ex. "192.168.0.16" |
|
|
-+ |
181 |
long destSocket '1 element for the socket number |
191 |
|
= |
182 |
|
192 |
'Misc variables |
|
183 |
'Misc variables |
193 |
byte data[_bytebuffersize] |
|
184 |
byte data[_bytebuffersize] |
194 |
long stack[50] |
|
185 |
long stack[50] |
|
|
<> |
186 |
|
|
|
|
187 |
long PageCount |
195 |
|
= |
188 |
|
196 |
'*************************************** |
|
189 |
'*************************************** |
197 |
OBJ 'Object declaration to be located here |
|
190 |
OBJ 'Object declaration to be located here |
198 |
'*************************************** |
|
191 |
'*************************************** |
199 |
|
|
192 |
|
200 |
'Choose which driver to use by commenting/uncommenting the driver. Only one can be chosen. |
|
193 |
'Choose which driver to use by commenting/uncommenting the driver. Only one can be chosen. |
201 |
ETHERNET : "Brilldea_W5100_Indirect_Driver_Ver006.spin" |
|
194 |
ETHERNET : "Brilldea_W5100_Indirect_Driver_Ver006.spin" |
202 |
|
|
195 |
|
203 |
'The serial terminal to use |
|
196 |
'The serial terminal to use |
204 |
PST : "Parallax Serial Terminal.spin" 'A terminal object created by Parallax, used for debugging |
|
197 |
PST : "Parallax Serial Terminal.spin" 'A terminal object created by Parallax, used for debugging |
205 |
|
|
198 |
|
|
|
<> |
199 |
'Utility |
|
|
|
200 |
STR :"STREngine.spin" 'A string processing utility |
|
|
|
201 |
|
206 |
'*************************************** |
= |
202 |
'*************************************** |
207 |
PUB main | temp0, temp1, temp2 |
<> |
203 |
PUB main | temp0, temp1, temp2, proc, ledState |
208 |
'*************************************** |
= |
204 |
'*************************************** |
209 |
'' First routine to be executed in the program |
|
205 |
'' First routine to be executed in the program |
210 |
'' because it is first PUB in the file |
|
206 |
'' because it is first PUB in the file |
211 |
|
|
207 |
|
212 |
PauseMSec(2_000) 'A small delay to allow time to switch to the terminal application after loading the device |
|
208 |
PauseMSec(2_000) 'A small delay to allow time to switch to the terminal application after loading the device |
213 |
|
|
209 |
|
214 |
'************************************** |
|
210 |
'************************************** |
215 |
' Start the processes in their cogs |
|
211 |
' Start the processes in their cogs |
216 |
'************************************** |
|
212 |
'************************************** |
217 |
|
|
213 |
|
218 |
'Start the terminal application |
|
214 |
'Start the terminal application |
219 |
'The terminal operates at 115,200 BAUD on the USB/COM Port the Prop Plug is attached to |
|
215 |
'The terminal operates at 115,200 BAUD on the USB/COM Port the Prop Plug is attached to |
220 |
PST.Start(115_200) |
|
216 |
PST.Start(115_200) |
221 |
|
|
217 |
|
222 |
'Start the W5100 driver |
|
218 |
'Start the W5100 driver |
223 |
ETHERNET.StartINDIRECT(_WIZ_data0, _WIZ_addr0, _WIZ_addr1, _WIZ_cs, _WIZ_rd, _WIZ_wr, _WIZ_rst, _WIZ_sen) |
|
219 |
ETHERNET.StartINDIRECT(_WIZ_data0, _WIZ_addr0, _WIZ_addr1, _WIZ_cs, _WIZ_rd, _WIZ_wr, _WIZ_rst, _WIZ_sen) |
224 |
|
|
220 |
|
225 |
'************************************** |
|
221 |
'************************************** |
226 |
' Initialize the variables |
|
222 |
' Initialize the variables |
227 |
'************************************** |
|
223 |
'************************************** |
228 |
|
|
224 |
|
229 |
'The following variables can be adjusted by the demo user to fit in their particular network application. |
|
225 |
'The following variables can be adjusted by the demo user to fit in their particular network application. |
230 |
'Note the MAC ID is a locally administered address. See Wikipedia MAC_Address |
|
226 |
'Note the MAC ID is a locally administered address. See Wikipedia MAC_Address |
231 |
|
|
227 |
|
232 |
'MAC ID to be assigned to W5100 |
|
228 |
'MAC ID to be assigned to W5100 |
233 |
MAC[0] := $02 |
<> |
229 |
MAC[0] := $00 |
234 |
MAC[1] := $00 |
|
230 |
MAC[1] := $08 |
235 |
MAC[2] := $00 |
|
231 |
MAC[2] := $DC |
236 |
MAC[3] := $01 |
|
232 |
MAC[3] := $16 |
237 |
MAC[4] := $23 |
|
233 |
MAC[4] := $EF |
238 |
MAC[5] := $45 |
|
234 |
MAC[5] := $06 |
|
|
|
235 |
'MAC[5] := $17 |
239 |
|
= |
236 |
|
240 |
'Subnet address to be assigned to W5100 |
|
237 |
'Subnet address to be assigned to W5100 |
241 |
Subnet[0] := 255 |
|
238 |
Subnet[0] := 255 |
242 |
Subnet[1] := 255 |
|
239 |
Subnet[1] := 255 |
243 |
Subnet[2] := 255 |
|
240 |
Subnet[2] := 255 |
244 |
Subnet[3] := 0 |
|
241 |
Subnet[3] := 0 |
245 |
|
|
242 |
|
246 |
'IP address to be assigned to W5100 |
|
243 |
'IP address to be assigned to W5100 |
247 |
IP[0] := 192 |
|
244 |
IP[0] := 192 |
248 |
IP[1] := 168 |
|
245 |
IP[1] := 168 |
249 |
IP[2] := 10 |
<> |
246 |
IP[2] := 4 |
250 |
IP[3] := 75 |
|
247 |
IP[3] := 180 |
|
|
|
248 |
'IP[3] := 181 |
251 |
|
= |
249 |
|
252 |
'Gateway address of the system network |
|
250 |
'Gateway address of the system network |
253 |
Gateway[0] := 192 |
|
251 |
Gateway[0] := 192 |
254 |
Gateway[1] := 168 |
|
252 |
Gateway[1] := 168 |
255 |
Gateway[2] := 10 |
<> |
253 |
Gateway[2] := 4 |
256 |
Gateway[3] := 1 |
= |
254 |
Gateway[3] := 1 |
257 |
|
|
255 |
|
258 |
'Local socket |
|
256 |
'Local socket |
259 |
socket := 5000 |
<> |
257 |
localSocket := 80 |
260 |
|
= |
258 |
|
261 |
'Destination IP address - can be left zeros, the TCO demo echoes to computer that sent the packet |
|
259 |
'Destination IP address - can be left zeros, the TCO demo echoes to computer that sent the packet |
262 |
destIP[0] := 0 |
|
260 |
destIP[0] := 0 |
263 |
destIP[1] := 0 |
|
261 |
destIP[1] := 0 |
264 |
destIP[2] := 0 |
|
262 |
destIP[2] := 0 |
265 |
destIP[3] := 0 |
|
263 |
destIP[3] := 0 |
|
|
<> |
264 |
|
|
|
|
265 |
destSocket := 80 |
266 |
|
= |
266 |
|
267 |
'************************************** |
|
267 |
'************************************** |
268 |
' Begin |
|
268 |
' Begin |
269 |
'************************************** |
|
269 |
'************************************** |
270 |
|
|
270 |
|
271 |
'Clear the terminal screen |
|
271 |
'Clear the terminal screen |
272 |
PST.Home |
|
272 |
PST.Home |
273 |
PST.Clear |
|
273 |
PST.Clear |
274 |
|
|
274 |
|
275 |
'Draw the title bar |
|
275 |
'Draw the title bar |
276 |
PST.Str(string(" W5100 Indirect Driver Test ", PST#NL)) |
<> |
|
|
277 |
PST.Str(string(" TCP Server Demo", PST#NL, PST#NL)) |
|
276 |
PST.Str(string(" Prop/W5100 Web Page Serving Test ", PST#NL, PST#NL)) |
278 |
|
= |
277 |
|
279 |
'Set the W5100 addresses |
|
278 |
'Set the W5100 addresses |
280 |
PST.Str(string("Initialize all addresses... ", PST#NL)) |
|
279 |
PST.Str(string("Initialize all addresses... ", PST#NL)) |
281 |
SetVerifyMAC(@MAC[0]) |
|
280 |
SetVerifyMAC(@MAC[0]) |
282 |
SetVerifyGateway(@Gateway[0]) |
|
281 |
SetVerifyGateway(@Gateway[0]) |
283 |
SetVerifySubnet(@Subnet[0]) |
|
282 |
SetVerifySubnet(@Subnet[0]) |
284 |
SetVerifyIP(@IP[0]) |
|
283 |
SetVerifyIP(@IP[0]) |
285 |
|
|
284 |
|
286 |
'Addresses should now be set and displayed in the terminal window. |
|
285 |
'Addresses should now be set and displayed in the terminal window. |
287 |
'Next initialize Socket 0 for being the TCP server |
|
286 |
'Next initialize Socket 0 for being the TCP server |
288 |
|
|
287 |
|
289 |
PST.Str(string("Initialize socket 0, port ")) |
|
288 |
PST.Str(string("Initialize socket 0, port ")) |
290 |
PST.dec(socket) |
<> |
289 |
PST.dec(localSocket) |
291 |
PST.Str(string(PST#NL)) |
= |
290 |
PST.Str(string(PST#NL)) |
292 |
|
|
291 |
|
293 |
'Testing Socket 0's status register and display information |
|
292 |
'Testing Socket 0's status register and display information |
294 |
PST.Str(string("Socket 0 Status Register: ")) |
|
293 |
PST.Str(string("Socket 0 Status Register: ")) |
295 |
ETHERNET.readIND(ETHERNET#_S0_SR, @temp0, 1) |
|
294 |
ETHERNET.readIND(ETHERNET#_S0_SR, @temp0, 1) |
296 |
|
|
295 |
|
297 |
case temp0 |
|
296 |
case temp0 |
298 |
ETHERNET#_SOCK_CLOSED : PST.Str(string("$00 - socket closed", PST#NL, PST#NL)) |
|
297 |
ETHERNET#_SOCK_CLOSED : PST.Str(string("$00 - socket closed", PST#NL, PST#NL)) |
299 |
ETHERNET#_SOCK_INIT : PST.Str(string("$13 - socket initalized", PST#NL, PST#NL)) |
|
298 |
ETHERNET#_SOCK_INIT : PST.Str(string("$13 - socket initalized", PST#NL, PST#NL)) |
300 |
ETHERNET#_SOCK_LISTEN : PST.Str(string("$14 - socket listening", PST#NL, PST#NL)) |
|
299 |
ETHERNET#_SOCK_LISTEN : PST.Str(string("$14 - socket listening", PST#NL, PST#NL)) |
301 |
ETHERNET#_SOCK_ESTAB : PST.Str(string("$17 - socket established", PST#NL, PST#NL)) |
|
300 |
ETHERNET#_SOCK_ESTAB : PST.Str(string("$17 - socket established", PST#NL, PST#NL)) |
302 |
ETHERNET#_SOCK_UDP : PST.Str(string("$22 - socket UDP open", PST#NL, PST#NL)) |
|
301 |
ETHERNET#_SOCK_UDP : PST.Str(string("$22 - socket UDP open", PST#NL, PST#NL)) |
303 |
|
|
302 |
|
304 |
'Try opening a socket using a ASM method |
|
303 |
'Try opening a socket using a ASM method |
305 |
PST.Str(string("Attempting to open TCP on socket 0, port ")) |
|
304 |
PST.Str(string("Attempting to open TCP on socket 0, port ")) |
306 |
PST.dec(socket) |
<> |
305 |
PST.dec(localSocket) |
307 |
PST.Str(string("...", PST#NL)) |
= |
306 |
PST.Str(string("...", PST#NL)) |
308 |
|
|
307 |
|
309 |
ETHERNET.SocketOpen(0, ETHERNET#_TCPPROTO, socket, socket, @destIP[0]) |
<> |
308 |
ETHERNET.SocketOpen(0, ETHERNET#_TCPPROTO, localSocket, destSocket, @destIP[0]) |
310 |
|
= |
309 |
|
311 |
'Wait a moment for the socket to get established |
|
310 |
'Wait a moment for the socket to get established |
312 |
PauseMSec(500) |
|
311 |
PauseMSec(500) |
313 |
|
|
312 |
|
314 |
'Testing Socket 0's status register and display information |
|
313 |
'Testing Socket 0's status register and display information |
315 |
PST.Str(string("Socket 0 Status Register: ")) |
|
314 |
PST.Str(string("Socket 0 Status Register: ")) |
316 |
ETHERNET.readIND(ETHERNET#_S0_SR, @temp0, 1) |
|
315 |
ETHERNET.readIND(ETHERNET#_S0_SR, @temp0, 1) |
317 |
|
|
316 |
|
318 |
case temp0 |
|
317 |
case temp0 |
319 |
ETHERNET#_SOCK_CLOSED : PST.Str(string("$00 - socket closed", PST#NL, PST#NL)) |
|
318 |
ETHERNET#_SOCK_CLOSED : PST.Str(string("$00 - socket closed", PST#NL, PST#NL)) |
320 |
ETHERNET#_SOCK_INIT : PST.Str(string("$13 - socket initalized/opened", PST#NL, PST#NL)) |
|
319 |
ETHERNET#_SOCK_INIT : PST.Str(string("$13 - socket initalized/opened", PST#NL, PST#NL)) |
321 |
ETHERNET#_SOCK_LISTEN : PST.Str(string("$14 - socket listening", PST#NL, PST#NL)) |
|
320 |
ETHERNET#_SOCK_LISTEN : PST.Str(string("$14 - socket listening", PST#NL, PST#NL)) |
322 |
ETHERNET#_SOCK_ESTAB : PST.Str(string("$17 - socket established", PST#NL, PST#NL)) |
|
321 |
ETHERNET#_SOCK_ESTAB : PST.Str(string("$17 - socket established", PST#NL, PST#NL)) |
323 |
ETHERNET#_SOCK_UDP : PST.Str(string("$22 - socket UDP open", PST#NL, PST#NL)) |
|
322 |
ETHERNET#_SOCK_UDP : PST.Str(string("$22 - socket UDP open", PST#NL, PST#NL)) |
324 |
|
|
323 |
|
325 |
'Try setting up a listen on the TCP socket |
|
324 |
'Try setting up a listen on the TCP socket |
326 |
PST.Str(string("Setting TCP on socket 0, port ")) |
|
325 |
PST.Str(string("Setting TCP on socket 0, port ")) |
327 |
PST.dec(socket) |
<> |
326 |
PST.dec(localSocket) |
328 |
PST.Str(string(" to listening", PST#NL)) |
= |
327 |
PST.Str(string(" to listening", PST#NL)) |
329 |
|
|
328 |
|
330 |
ETHERNET.SocketTCPlisten(0) |
|
329 |
ETHERNET.SocketTCPlisten(0) |
331 |
|
|
330 |
|
332 |
'Wait a moment for the socket to listen |
|
331 |
'Wait a moment for the socket to listen |
333 |
PauseMSec(500) |
|
332 |
PauseMSec(500) |
334 |
|
|
333 |
|
335 |
'Testing Socket 0's status register and display information |
|
334 |
'Testing Socket 0's status register and display information |
336 |
PST.Str(string("Socket 0 Status Register: ")) |
|
335 |
PST.Str(string("Socket 0 Status Register: ")) |
337 |
ETHERNET.readIND(ETHERNET#_S0_SR, @temp0, 1) |
|
336 |
ETHERNET.readIND(ETHERNET#_S0_SR, @temp0, 1) |
338 |
|
|
337 |
|
339 |
case temp0 |
|
338 |
case temp0 |
340 |
ETHERNET#_SOCK_CLOSED : PST.Str(string("$00 - socket closed", PST#NL, PST#NL)) |
|
339 |
ETHERNET#_SOCK_CLOSED : PST.Str(string("$00 - socket closed", PST#NL, PST#NL)) |
341 |
ETHERNET#_SOCK_INIT : PST.Str(string("$13 - socket initalized", PST#NL, PST#NL)) |
|
340 |
ETHERNET#_SOCK_INIT : PST.Str(string("$13 - socket initalized", PST#NL, PST#NL)) |
342 |
ETHERNET#_SOCK_LISTEN : PST.Str(string("$14 - socket listening", PST#NL, PST#NL)) |
|
341 |
ETHERNET#_SOCK_LISTEN : PST.Str(string("$14 - socket listening", PST#NL, PST#NL)) |
343 |
ETHERNET#_SOCK_ESTAB : PST.Str(string("$17 - socket established", PST#NL, PST#NL)) |
|
342 |
ETHERNET#_SOCK_ESTAB : PST.Str(string("$17 - socket established", PST#NL, PST#NL)) |
344 |
ETHERNET#_SOCK_UDP : PST.Str(string("$22 - socket UDP open", PST#NL, PST#NL)) |
|
343 |
ETHERNET#_SOCK_UDP : PST.Str(string("$22 - socket UDP open", PST#NL, PST#NL)) |
345 |
|
|
344 |
|
|
|
-+ |
345 |
PageCount := 0 |
|
|
|
346 |
ledState := 1 |
|
|
|
347 |
dira[_LED] := 1 |
346 |
'Infinite loop of the server |
= |
348 |
'Infinite loop of the server |
347 |
repeat |
|
349 |
repeat |
348 |
|
|
350 |
|
349 |
'Waiting for a client to connect |
|
351 |
'Waiting for a client to connect |
350 |
PST.Str(string("Waiting for a client to connect....", PST#NL)) |
|
352 |
PST.Str(string("Waiting for a client to connect....", PST#NL)) |
351 |
|
|
353 |
|
352 |
'Testing Socket 0's status register and looking for a client to connect to our server |
|
354 |
'Testing Socket 0's status register and looking for a client to connect to our server |
353 |
repeat while !ETHERNET.SocketTCPestablished(0) |
|
355 |
repeat while !ETHERNET.SocketTCPestablished(0) |
354 |
|
|
356 |
|
355 |
'Connection established |
|
357 |
'Connection established |
356 |
PST.Str(string("connection established, send TCP packet to be echoed", PST#NL)) |
<> |
358 |
PST.Str(string("connection established...")) |
357 |
|
= |
359 |
|
358 |
temp0 := 0 |
<> |
360 |
'Initialize the buffers and bring the data over |
359 |
bytefill(@data, 0, _bytebuffersize) |
|
361 |
bytefill(@data, 0, _bytebuffersize) |
|
|
|
362 |
ETHERNET.rxTCP(0, @data) |
|
|
|
363 |
'PST.Str(@data) 'print out full HTTP request |
360 |
|
= |
364 |
|
361 |
repeat while ETHERNET.SocketTCPestablished(0) |
<> |
365 |
{ FMO: 20101120 modify start} |
362 |
|
|
366 |
{ |
363 |
PST.Str(string("Waiting to receive....")) |
|
367 |
This code change is only a proof of concept for an AJAX enabled client/server demo |
|
|
|
368 |
It requires proper file, request and response API handlers |
|
|
|
369 |
It also requires proper encapsulation modulues |
364 |
|
= |
370 |
|
365 |
repeat until temp0 := ETHERNET.rxTCP(0, @data[0]) |
<> |
371 |
The AJAX design pattern is... |
366 |
ifnot ETHERNET.SocketTCPestablished(0) |
|
372 |
1) the server serves out a html response containing both |
|
|
|
373 |
the client side JavaScript code and |
|
|
|
374 |
the HTML DOM processing code that displays dynamic XML data from the server |
|
|
|
375 |
2) the XMLHttpRequest object handles requests for XML data and parsing of the |
367 |
quit |
|
376 |
XML text response. |
368 |
|
|
377 |
It is up to the client-side developer to manipulate the DOM of the |
369 |
ifnot ETHERNET.SocketTCPestablished(0) |
|
378 |
client page in response to what is recieved from an asynchronous GET request. |
370 |
PST.Str(string(PST#NL)) |
|
379 |
In my case I respond both to mouse-overs and a timer request to send server requests. |
371 |
quit |
|
380 |
|
|
|
|
381 |
Currently this code works fine with Google Chrome (sometimes after a couple refreshes up to 10 sec after a propeller reset) |
|
|
|
382 |
The AJAX code works fine with IE from a desktop server but IE8 has issues with the line |
|
|
|
383 |
this._xmlHttp = new FactoryXMLHttpRequest() |
372 |
|
= |
384 |
|
|
|
<> |
385 |
} |
|
|
|
386 |
|
|
|
|
387 |
' Get response is |
|
|
|
388 |
'GET /app?param=x¶m2=y... HTTP/1.1 |
|
|
|
389 |
|
|
|
|
390 |
if data[0] == "G" |
|
|
|
391 |
PageCount++ |
|
|
|
392 |
' very-hacky but until proper param work by Bean is used I am just ckecking for "any" get encoding |
|
|
|
393 |
' this must match |
|
|
|
394 |
if data[7] == "a" |
|
|
|
395 |
ledState := 1 - ledState |
|
|
|
396 |
outa[_LED] := ledState |
|
|
|
397 |
|
|
|
|
398 |
' service AJAX XML response |
|
|
|
399 |
PST.Str(string("serving XML Async GET ")) |
|
|
|
400 |
PST.dec(PageCount) |
|
|
|
401 |
PST.Str(string(PST#NL)) |
|
|
|
402 |
' Currently the XML tag schema is kind of irrelevant |
|
|
|
403 |
StringSend(0, string("<xml>")) |
|
|
|
404 |
StringSend(0, string("<data>")) |
|
|
|
405 |
' this actual element text between tags will be parsed out by the client |
|
|
|
406 |
StringSend(0, STR.numberToDecimal(PageCount, 6)) |
|
|
|
407 |
StringSend(0, string("</data>")) |
|
|
|
408 |
StringSend(0, string("</xml>")) |
|
|
|
409 |
else |
|
|
|
410 |
outa[_LED] := 1 |
|
|
|
411 |
|
373 |
PST.Str(string("received ")) |
|
412 |
PST.Str(string("serving page ")) |
374 |
PST.dec(temp0) |
|
413 |
PST.dec(PageCount) |
|
|
|
414 |
PST.Str(string(PST#NL)) |
|
|
|
415 |
|
|
|
|
416 |
'Send the web page - hardcoded here |
|
|
|
417 |
'File |
|
|
|
418 |
{ ' fmo commenting Timothy's code |
|
|
|
419 |
StringSend(0, string("<html><title>spinneret.cassidydevelopment.net</title>")) |
|
|
|
420 |
StringSend(0, string("<font face=Arial size=5>Welcome to spinneret.cassidydevelopment.net</font><br>")) |
|
|
|
421 |
StringSend(0, string("<font face=Arial size=4>Thanks Timothy Swieter<br><br><br>")) |
375 |
PST.Str(string(" bytes and echoing....")) |
|
422 |
StringSend(0, string("You are Visitor: ")) |
|
|
|
423 |
StringSend(0, STR.numberToDecimal(PageCount, 5)) |
|
|
|
424 |
StringSend(0, string("<br><br><br>")) |
|
|
|
425 |
StringSend(0, string("<u>Things I would like to do next:</u><br>")) |
|
|
|
426 |
StringSend(0, string("- Collect Visitor IP/MAC/Client Info<br>")) |
|
|
|
427 |
StringSend(0, string("- Handle Forms<br>")) |
|
|
|
428 |
StringSend(0, string("- Serve Multiple Files/Pages<br>")) |
|
|
|
429 |
StringSend(0, string("- Interact with the RTC<br>")) |
|
|
|
430 |
StringSend(0, string("- Interact with the uSD<br>")) |
|
|
|
431 |
StringSend(0, string("- Many Fun Things to Come :)")) |
|
|
|
432 |
StringSend(0, string("</html>")) |
376 |
|
|
433 |
} |
377 |
ETHERNET.txTCP(0, @data[0], temp0) |
|
434 |
|
|
|
|
435 |
|
|
|
|
436 |
'StringSend(0, string(" <%@ page language='java' contentType='text/html",59," charset=ISO-8859-1'")) |
|
|
|
437 |
'StringSend(0, string(" pageEncoding='ISO-8859-1%>'")) |
|
|
|
438 |
proc := 0 ' this variable needs a for loop - but I need to get rid of the leading space when using numberToDecimal |
|
|
|
439 |
'StringSend(0, string("<!DOCTYPE html PUBLIC ",34,"-//W3C//DTD HTML 4.01 Transitional//EN",34,">")) |
|
|
|
440 |
StringSend(0, string("<html>")) |
|
|
|
441 |
StringSend(0, string("<head>")) |
|
|
|
442 |
'StringSend(0, string(" <meta http-equiv='Content-Type' content='text/html'",59,"; charset='ISO-8859-1'>")) |
|
|
|
443 |
'StringSend(0, string(" <meta http-equiv='Content-Style-Type' content='text/css'>")) |
|
|
|
444 |
'StringSend(0, string(" <meta http-equiv='expires' content='Wed, 26 Feb 1997 08:21:57 GMT'>")) ' expire to clear cache |
|
|
|
445 |
'StringSend(0, string(" <link rel='stylesheet' type='text/css' href='styles.css'>")) |
|
|
|
446 |
StringSend(0, string("<style type=text/css>",13,10)) |
|
|
|
447 |
StringSend(0, string(" A:link {COLOR: #f0f000}",13,10)) |
|
|
|
448 |
StringSend(0, string(" A:visited {COLOR: #00a0a0}",13,10)) |
|
|
|
449 |
StringSend(0, string(" A:hover {COLOR: #f00000}",13,10)) |
|
|
|
450 |
StringSend(0, string(" .hidden {VISIBILITY: hidden}",13,10)) |
|
|
|
451 |
StringSend(0, string(" DIV {COLOR: #669966; FONT-FAMILY: Arial, Verdana, Helvetica}",13,10)) |
|
|
|
452 |
StringSend(0, string(" .ref2-d {COLOR: #bfbfff; FONT-SIZE: 8pt; LINE-HEIGHT:10pt; TEXT-DECORATION: none }",13,10)) |
|
|
|
453 |
StringSend(0, string(" .refdesc-d {COLOR: #f0f0ff; FONT-SIZE: 11pt; LINE-HEIGHT: 11pt; TEXT-DECORATION: none; text-indent: 3}",13,10)) |
|
|
|
454 |
StringSend(0, string(" .refdesc {COLOR: #000080; FONT-SIZE: 11pt; LINE-HEIGHT: 11pt; TEXT-DECORATION: none; text-indent: 30}",13,10)) |
|
|
|
455 |
StringSend(0, string(" .refdesc2 {COLOR: #000080; FONT-SIZE: 10pt; LINE-HEIGHT: 10pt; TEXT-DECORATION: none; text-indent: 30}",13,10)) |
|
|
|
456 |
StringSend(0, string(" .refline {COLOR: #000000; FONT-SIZE: 12pt; LINE-HEIGHT: 12pt; TEXT-DECORATION: none }",13,10)) |
|
|
|
457 |
StringSend(0, string(" .refdesc2-d {COLOR: #d0d0ff; FONT-SIZE: 10pt; LINE-HEIGHT: 10pt; TEXT-DECORATION: none; text-indent: 30}",13,10)) |
|
|
|
458 |
StringSend(0, string(" .refline-d {COLOR: #ffffff; FONT-SIZE: 12pt; LINE-HEIGHT: 12pt; TEXT-DECORATION: none }",13,10)) |
|
|
|
459 |
StringSend(0, string(" .ref {COLOR: #003f3f; FONT-SIZE: 8pt; LINE-HEIGHT: 10pt; TEXT-DECORATION: none }",13,10)) |
|
|
|
460 |
StringSend(0, string(" .ref-d {COLOR: #00ffff; FONT-SIZE: 8pt; LINE-HEIGHT:10pt; TEXT-DECORATION: none }",13,10)) |
|
|
|
461 |
StringSend(0, string(" .ref2 {COLOR: #00003f; FONT-SIZE: 8pt; LINE-HEIGHT: 10pt; TEXT-DECORATION: none }",13,10)) |
|
|
|
462 |
StringSend(0, string("</style>",13,10)) |
|
|
|
463 |
|
|
|
|
464 |
StringSend(0, string("<title>DataParallel Active Client</title>",13,10)) |
|
|
|
465 |
'StringSend(0, string("<% int processingUnits = 16; %>")) |
|
|
|
466 |
StringSend(0, string("<script language=",34,"JavaScript",34," type=",34,"text/javascript",34,">")) |
|
|
|
467 |
StringSend(0, string(" function FactoryXMLHttpRequest() {",13,10)) |
|
|
|
468 |
StringSend(0, string(" if(window.XMLHttpRequest) {",13,10)) |
|
|
|
469 |
StringSend(0, string(" // Mozilla",13,10)) |
|
|
|
470 |
StringSend(0, string(" return new XMLHttpRequest()",59,13,10)) |
|
|
|
471 |
StringSend(0, string(" } else if(window.ActiveXObject) {",13,10)) |
|
|
|
472 |
StringSend(0, string(" try {",13,10)) |
|
|
|
473 |
StringSend(0, string(" // Internet Explorer only",13,10)) |
|
|
|
474 |
StringSend(0, string(" return new ActiveXObject(",34,"Microsoft.XMLHTTP",34,")",59,13,10)) |
|
|
|
475 |
StringSend(0, string(" } catch (e) {",13,10)) |
|
|
|
476 |
StringSend(0, string(" }",13,10)) |
|
|
|
477 |
StringSend(0, string(" }",13,10)) |
|
|
|
478 |
StringSend(0, string(" // Verify Chrome, Firefox, Opera and Apple",13,10)) |
|
|
|
479 |
StringSend(0, string(" throw new Error(",34,"Could not get an AJAX XMLHttpRequest Object",34,")",59,13,10)) |
|
|
|
480 |
StringSend(0, string(" } ",13,10)) |
|
|
|
481 |
StringSend(0, string(" function Ajax() {",13,10)) |
|
|
|
482 |
'StringSend(0, string(" new ActiveXObject(",34,"Microsoft.XMLHTTP",34,")"))'new FactoryXMLHttpRequest()",59,13,10)) |
|
|
|
483 |
' this line will not load in IE8 but works fine in Google Chrome |
|
|
|
484 |
StringSend(0, string(" this._xmlHttp = new FactoryXMLHttpRequest()",59,13,10)) |
|
|
|
485 |
'StringSend(0, string(" this._xmlHttp = null"))'new ActiveXObject(",34,"Microsoft.XMLHTTP",34,")"))'new FactoryXMLHttpRequest()",59,13,10)) |
|
|
|
486 |
StringSend(0, string(" }",13,10)) |
|
|
|
487 |
StringSend(0, string(" // This code is loosely based on",13,10)) |
|
|
|
488 |
StringSend(0, string(" // p.22 of Ajax Patterns and Best Practices by Christian Gross (2006)",13,10)) |
|
|
|
489 |
StringSend(0, string(" // http://books.google.com/books?id=qNzBbUWhGM0C&printsec=frontcover&dq=ajax+patterns+and&cd=2#v=onepage&q&f=false",13,10)) |
|
|
|
490 |
'StringSend(0, string(" // and http://www.w3schools.com/js/js_timing.asp",13,10)) |
|
|
|
491 |
StringSend(0, string(" function AjaxUpdateEvent(elementId, status, statusText, responseText, responseXML) {",13,10)) |
|
|
|
492 |
StringSend(0, string(" document.getElementById(elementId).innerHTML = responseText",59,13,10)) |
|
|
|
493 |
StringSend(0, string(" }",13,10)) |
|
|
|
494 |
StringSend(0, string(" // Timer variables",13,10)) |
|
|
|
495 |
StringSend(0, string(" var timers = new Array()",59,13,10)) |
|
|
|
496 |
StringSend(0, string(" var timerStateArray = new Array()",59,13,10)) |
|
|
|
497 |
StringSend(0, string(" var ajax = new Array()",59,13,10)) |
|
|
|
498 |
StringSend(0, string(" // initialize all arrays",13,10)) |
|
|
|
499 |
'StringSend(0, string(" for (i=0",59,"i<<1>",59,"i=i+1) {",13,10)) |
|
|
|
500 |
StringSend(0, string(" timerStateArray[0] = 0",59,13,10)) |
|
|
|
501 |
StringSend(0, string(" ajax[0] = new Ajax()",59,13,10)) |
|
|
|
502 |
StringSend(0, string(" ajax[0].complete = AjaxUpdateEvent",59,13,10)) |
|
|
|
503 |
'StringSend(0, string(" }",13,10)) |
|
|
|
504 |
StringSend(0, string(" function Ajax_call(url, elementId) {",13,10)) |
|
|
|
505 |
StringSend(0, string(" var instance = this",59,13,10)) |
|
|
|
506 |
StringSend(0, string(" this._xmlHttp.open('GET', url, true)",59,13,10)) |
|
|
|
507 |
StringSend(0, string(" // inner anonymous function",13,10)) |
|
|
|
508 |
StringSend(0, string(" this._xmlHttp.onreadystatechange = function() {",13,10)) |
|
|
|
509 |
StringSend(0, string(" switch(instance._xmlHttp.readyState) {",13,10)) |
|
|
|
510 |
StringSend(0, string(" case 1:",13,10)) |
|
|
|
511 |
StringSend(0, string(" instance.loading()",59,13,10)) |
|
|
|
512 |
StringSend(0, string(" break",59,13,10)) |
|
|
|
513 |
StringSend(0, string(" case 2:",13,10)) |
|
|
|
514 |
StringSend(0, string(" instance.loaded()",59,13,10)) |
|
|
|
515 |
StringSend(0, string(" break;",13,10)) |
|
|
|
516 |
StringSend(0, string(" case 3:",13,10)) |
|
|
|
517 |
StringSend(0, string(" instance.interactive()",59,13,10)) |
|
|
|
518 |
StringSend(0, string(" break",59,13,10)) |
|
|
|
519 |
StringSend(0, string(" case 4:",13,10)) |
|
|
|
520 |
StringSend(0, string(" // pass parameters",13,10)) |
|
|
|
521 |
StringSend(0, string(" instance.complete(",13,10)) |
|
|
|
522 |
StringSend(0, string(" elementId,",13,10)) |
|
|
|
523 |
StringSend(0, string(" instance._xmlHttp.status,",13,10)) |
|
|
|
524 |
StringSend(0, string(" instance._xmlHttp.statusText,",13,10)) |
|
|
|
525 |
StringSend(0, string(" instance._xmlHttp.responseText,",13,10)) |
|
|
|
526 |
StringSend(0, string(" instance._xmlHttp.responseXML)",59,13,10)) |
|
|
|
527 |
StringSend(0, string(" break",59,13,10)) |
|
|
|
528 |
StringSend(0, string(" }",13,10)) |
|
|
|
529 |
StringSend(0, string(" }",59,13,10)) |
|
|
|
530 |
StringSend(0, string(" this._xmlHttp.send(null)",59,13,10)) |
|
|
|
531 |
StringSend(0, string(" }",13,10)) |
|
|
|
532 |
StringSend(0, string(" function Ajax_loading(){ }",13,10)) |
|
|
|
533 |
StringSend(0, string(" function Ajax_loaded(){ }",13,10)) |
|
|
|
534 |
StringSend(0, string(" function Ajax_interactive(){ }",13,10)) |
|
|
|
535 |
StringSend(0, string(" function Ajax_complete(elementId, status, statusText, responseText, responseHTML){ }",13,10)) |
|
|
|
536 |
StringSend(0, string(" // create static class functions",13,10)) |
|
|
|
537 |
StringSend(0, string(" Ajax.prototype.loading = Ajax_loading",59,13,10)) |
|
|
|
538 |
StringSend(0, string(" Ajax.prototype.loaded = Ajax_loaded",59,13,10)) |
|
|
|
539 |
StringSend(0, string(" Ajax.prototype.interactive = Ajax_interactive",59,13,10)) |
|
|
|
540 |
StringSend(0, string(" Ajax.prototype.complete = Ajax_complete",59,13,10)) |
|
|
|
541 |
StringSend(0, string(" Ajax.prototype.call = Ajax_call",59,13,10)) |
|
|
|
542 |
StringSend(0, string(" // Base case: Switch the timer flag and call the main loop",13,10)) |
|
|
|
543 |
StringSend(0, string(" function doTimer(url,cell,speed,elementId) {",13,10)) |
|
|
|
544 |
StringSend(0, string(" if(!timerStateArray[cell]) {",13,10)) |
|
|
|
545 |
StringSend(0, string(" timerStateArray[cell] = 1",59,13,10)) |
|
|
|
546 |
StringSend(0, string(" timedCall(url,cell,speed,elementId)",59,13,10)) |
|
|
|
547 |
StringSend(0, string(" }",13,10)) |
|
|
|
548 |
StringSend(0, string(" }",13,10)) |
|
|
|
549 |
StringSend(0, string(" // Main timing loop calls itself",13,10)) |
|
|
|
550 |
StringSend(0, string(" function timedCall(url,cell,speed,elementId) {",13,10)) |
|
|
|
551 |
StringSend(0, string(" ajax[cell].call(url,elementId)",59,13,10)) |
|
|
|
552 |
StringSend(0, string(" if(timerStateArray[cell]) {",13,10)) |
|
|
|
553 |
StringSend(0, string(" timers[cell] = setTimeout(function() { timedCall(url,cell,speed,elementId)",59," }, speed)",59," // no speed = max speed",13,10)) |
|
|
|
554 |
StringSend(0, string(" }")) |
378 |
PST.Str(string("sent", PST#NL)) |
|
555 |
StringSend(0, string(" }")) |
|
|
|
556 |
StringSend(0, string("</script>")) |
|
|
|
557 |
StringSend(0, string("</head>",13,10)) |
|
|
|
558 |
StringSend(0, string("<body text='#ffffff' bgcolor='#303030' link='#33D033' vlink='#D030D0' alink='#D03000'>",13,10)) |
|
|
|
559 |
'StringSend(0, string("<!-- @&rnd=<%=String.valueOf(Math.random())%>')"-->")) |
|
|
|
560 |
StringSend(0, string(" <table border='0'>",13,10)) |
|
|
|
561 |
'StringSend(0, string(" <%")) |
|
|
|
562 |
'StringSend(0, string(" for(int i=0;i<processingUnits;i++) {")) |
|
|
|
563 |
'StringSend(0, string(" out.println("<tr bgcolor=\"#2d1d4f\">");")) |
|
|
|
564 |
'StringSend(0, string(" out.println("<td><span id=\"" + i + "\" class=\"refdesc-d\">" + i + "</span>");")) |
|
|
|
565 |
'StringSend(0, string(" out.println("</td>");")) |
|
|
|
566 |
'StringSend(0, string(" out.println("<td><span id=\"b" + i + "\">");")) |
|
|
|
567 |
'StringSend(0, string(" out.println(" <button ");")) |
|
|
|
568 |
'StringSend(0, string(" out.println("onMouseOver=\"ajax[" + i + "].call('/dpservice/FrontController?action=demo&cell=" + i + "','" + i + "')\" ");")) |
|
|
|
569 |
'StringSend(0, string(" out.println("onclick=\"doTimer('/dpservice/FrontController?action=demo&cell=" + i + "'," + i + ",200,'" + i + "')\">on</button>");")) |
|
|
|
570 |
'StringSend(0, string(" out.println(" <button ");")) |
|
|
|
571 |
'StringSend(0, string(" out.println("onclick=\"timerStateArray[" + i + "]=0\">off</button>");")) |
|
|
|
572 |
'StringSend(0, string(" out.println("</span>");")) |
|
|
|
573 |
'StringSend(0, string(" out.println("</td>");")) |
|
|
|
574 |
'StringSend(0, string(" out.println("</tr>");")) |
|
|
|
575 |
StringSend(0, string(" <tr bgcolor='#2d1d4f'>",13,10)) |
|
|
|
576 |
StringSend(0, string(" <td><span id='")) |
|
|
|
577 |
StringSend(0, string("0"))'STR.numberToDecimal(proc, 1)) |
|
|
|
578 |
StringSend(0, string("' class='refdesc-d'>")) |
|
|
|
579 |
StringSend(0, string("0"))'STR.numberToDecimal(proc, 1)) |
|
|
|
580 |
StringSend(0, string(" </span>",13,10)) |
|
|
|
581 |
StringSend(0, string(" </td>",13,10)) |
|
|
|
582 |
StringSend(0, string(" <td><span id=",34,"b0",34,">")) |
|
|
|
583 |
StringSend(0, string(" <button onMouseOver=",34,"ajax[")) |
|
|
|
584 |
StringSend(0, string("0"))'STR.numberToDecimal(proc, 1)) |
|
|
|
585 |
StringSend(0, string("].call('0=ajax")) |
|
|
|
586 |
StringSend(0, string("0"))'STR.numberToDecimal(proc, 1)) |
|
|
|
587 |
StringSend(0, string("'",",'")) |
|
|
|
588 |
StringSend(0, string("0"))'STR.numberToDecimal(proc, 1)) |
|
|
|
589 |
StringSend(0, string("')",34,13,10)) |
|
|
|
590 |
StringSend(0, string(" onclick=",34,"doTimer('0=ajax")) |
|
|
|
591 |
StringSend(0, string("0"))'STR.numberToDecimal(proc, 1)) |
|
|
|
592 |
StringSend(0, string("',")) |
|
|
|
593 |
StringSend(0, string("0"))'STR.numberToDecimal(proc, 1)) |
|
|
|
594 |
StringSend(0, string(",200,'")) |
|
|
|
595 |
StringSend(0, string("0"))'STR.numberToDecimal(proc, 1)) |
|
|
|
596 |
StringSend(0, string("')",34,">on</button>",13,10)) |
|
|
|
597 |
StringSend(0, string(" <button ")) |
|
|
|
598 |
StringSend(0, string("onclick=",34,"timerStateArray[")) |
|
|
|
599 |
StringSend(0, string("0"))'STR.numberToDecimal(proc, 1)) |
|
|
|
600 |
StringSend(0, string("]=0",34,">off</button>",13,10)) |
|
|
|
601 |
StringSend(0, string(" </span>",13,10)) |
|
|
|
602 |
StringSend(0, string(" </td>",13,10)) |
|
|
|
603 |
StringSend(0, string(" </tr>",13,10)) |
|
|
|
604 |
'StringSend(0, string(" }")) |
|
|
|
605 |
'StringSend(0, string(" %>")) |
|
|
|
606 |
StringSend(0, string(" </table>",13,10)) |
|
|
|
607 |
StringSend(0, string(" <br/><br/><br/><br/><br/>")) |
|
|
|
608 |
StringSend(0, string(" <p class='ref2'>Make sure that 'Tools | Internet Options | Browsing History - is set to 'Every time I visit the webpage' instead of the default 'Automatically' so the XMLHttpRequest call will reach the server on subsequent calls.</p>",13,10)) |
|
|
|
609 |
StringSend(0, string("</body>")) |
|
|
|
610 |
StringSend(0, string("</html>")) |
379 |
|
= |
611 |
|
|
|
<> |
612 |
|
|
|
|
613 |
{ FMO: 20101120 modify end } |
|
|
|
614 |
|
|
|
|
615 |
PauseMSec(5) |
|
|
|
616 |
|
|
|
|
617 |
'End the connection |
|
|
|
618 |
ETHERNET.SocketTCPdisconnect(0) |
|
|
|
619 |
|
|
|
|
620 |
PauseMSec(10) |
|
|
|
621 |
|
380 |
'Connection terminated |
= |
622 |
'Connection terminated |
381 |
PST.Str(string("Connection disconnected", PST#NL, PST#NL)) |
+- |
|
|
382 |
ETHERNET.SocketClose(0) |
= |
623 |
ETHERNET.SocketClose(0) |
|
|
-+ |
624 |
PST.Str(string("Connection complete", PST#NL, PST#NL)) |
383 |
|
= |
625 |
|
384 |
'Once the connection is closed, need to open socket again |
|
626 |
'Once the connection is closed, need to open socket again |
385 |
OpenSocketAgain |
|
627 |
OpenSocketAgain |
386 |
|
|
628 |
|
387 |
return 'end of main |
|
629 |
return 'end of main |
388 |
|
|
630 |
|
389 |
'*************************************** |
|
631 |
'*************************************** |
390 |
PRI SetVerifyMAC(_firstOctet) |
|
632 |
PRI SetVerifyMAC(_firstOctet) |
391 |
'*************************************** |
|
633 |
'*************************************** |
392 |
|
|
634 |
|
393 |
'Set the MAC ID and display it in the terminal |
|
635 |
'Set the MAC ID and display it in the terminal |
394 |
ETHERNET.WriteMACaddress(true, _firstOctet) |
|
636 |
ETHERNET.WriteMACaddress(true, _firstOctet) |
395 |
|
|
637 |
|
396 |
|
|
638 |
|
397 |
PST.Str(string(" Set MAC ID........")) |
|
639 |
PST.Str(string(" Set MAC ID........")) |
398 |
PST.hex(byte[_firstOctet + 0], 2) |
|
640 |
PST.hex(byte[_firstOctet + 0], 2) |
399 |
PST.Str(string(":")) |
|
641 |
PST.Str(string(":")) |
400 |
PST.hex(byte[_firstOctet + 1], 2) |
|
642 |
PST.hex(byte[_firstOctet + 1], 2) |
401 |
PST.Str(string(":")) |
|
643 |
PST.Str(string(":")) |
402 |
PST.hex(byte[_firstOctet + 2], 2) |
|
644 |
PST.hex(byte[_firstOctet + 2], 2) |
403 |
PST.Str(string(":")) |
|
645 |
PST.Str(string(":")) |
404 |
PST.hex(byte[_firstOctet + 3], 2) |
|
646 |
PST.hex(byte[_firstOctet + 3], 2) |
405 |
PST.Str(string(":")) |
|
647 |
PST.Str(string(":")) |
406 |
PST.hex(byte[_firstOctet + 4], 2) |
|
648 |
PST.hex(byte[_firstOctet + 4], 2) |
407 |
PST.Str(string(":")) |
|
649 |
PST.Str(string(":")) |
408 |
PST.hex(byte[_firstOctet + 5], 2) |
|
650 |
PST.hex(byte[_firstOctet + 5], 2) |
409 |
PST.Str(string(PST#NL)) |
|
651 |
PST.Str(string(PST#NL)) |
410 |
|
|
652 |
|
411 |
'Wait a moment |
|
653 |
'Wait a moment |
412 |
PauseMSec(500) |
|
654 |
PauseMSec(500) |
413 |
|
|
655 |
|
414 |
ETHERNET.ReadMACAddress(@vMAC[0]) |
|
656 |
ETHERNET.ReadMACAddress(@vMAC[0]) |
415 |
|
|
657 |
|
416 |
PST.Str(string(" Verified MAC ID...")) |
|
658 |
PST.Str(string(" Verified MAC ID...")) |
417 |
PST.hex(vMAC[0], 2) |
|
659 |
PST.hex(vMAC[0], 2) |
418 |
PST.Str(string(":")) |
|
660 |
PST.Str(string(":")) |
419 |
PST.hex(vMAC[1], 2) |
|
661 |
PST.hex(vMAC[1], 2) |
420 |
PST.Str(string(":")) |
|
662 |
PST.Str(string(":")) |
421 |
PST.hex(vMAC[2], 2) |
|
663 |
PST.hex(vMAC[2], 2) |
422 |
PST.Str(string(":")) |
|
664 |
PST.Str(string(":")) |
423 |
PST.hex(vMAC[3], 2) |
|
665 |
PST.hex(vMAC[3], 2) |
424 |
PST.Str(string(":")) |
|
666 |
PST.Str(string(":")) |
425 |
PST.hex(vMAC[4], 2) |
|
667 |
PST.hex(vMAC[4], 2) |
426 |
PST.Str(string(":")) |
|
668 |
PST.Str(string(":")) |
427 |
PST.hex(vMAC[5], 2) |
|
669 |
PST.hex(vMAC[5], 2) |
428 |
PST.Str(string(PST#NL)) |
|
670 |
PST.Str(string(PST#NL)) |
429 |
PST.Str(string(PST#NL)) |
|
671 |
PST.Str(string(PST#NL)) |
430 |
|
|
672 |
|
431 |
return 'end of SetVerifyMAC |
|
673 |
return 'end of SetVerifyMAC |
432 |
|
|
674 |
|
433 |
'*************************************** |
|
675 |
'*************************************** |
434 |
PRI SetVerifyGateway(_firstOctet) |
|
676 |
PRI SetVerifyGateway(_firstOctet) |
435 |
'*************************************** |
|
677 |
'*************************************** |
436 |
|
|
678 |
|
437 |
'Set the Gatway address and display it in the terminal |
|
679 |
'Set the Gatway address and display it in the terminal |
438 |
ETHERNET.WriteGatewayAddress(true, _firstOctet) |
|
680 |
ETHERNET.WriteGatewayAddress(true, _firstOctet) |
439 |
|
|
681 |
|
440 |
PST.Str(string(" Set Gateway.....")) |
|
682 |
PST.Str(string(" Set Gateway.....")) |
441 |
PST.dec(byte[_firstOctet + 0]) |
|
683 |
PST.dec(byte[_firstOctet + 0]) |
442 |
PST.Str(string(".")) |
|
684 |
PST.Str(string(".")) |
443 |
PST.dec(byte[_firstOctet + 1]) |
|
685 |
PST.dec(byte[_firstOctet + 1]) |
444 |
PST.Str(string(".")) |
|
686 |
PST.Str(string(".")) |
445 |
PST.dec(byte[_firstOctet + 2]) |
|
687 |
PST.dec(byte[_firstOctet + 2]) |
446 |
PST.Str(string(".")) |
|
688 |
PST.Str(string(".")) |
447 |
PST.dec(byte[_firstOctet + 3]) |
|
689 |
PST.dec(byte[_firstOctet + 3]) |
448 |
PST.Str(string(PST#NL)) |
|
690 |
PST.Str(string(PST#NL)) |
449 |
|
|
691 |
|
450 |
'Wait a moment |
|
692 |
'Wait a moment |
451 |
PauseMSec(500) |
|
693 |
PauseMSec(500) |
452 |
|
|
694 |
|
453 |
ETHERNET.ReadGatewayAddress(@vGATEWAY[0]) |
|
695 |
ETHERNET.ReadGatewayAddress(@vGATEWAY[0]) |
454 |
|
|
696 |
|
455 |
PST.Str(string(" Verified Gateway..")) |
|
697 |
PST.Str(string(" Verified Gateway..")) |
456 |
PST.dec(vGATEWAY[0]) |
|
698 |
PST.dec(vGATEWAY[0]) |
457 |
PST.Str(string(".")) |
|
699 |
PST.Str(string(".")) |
458 |
PST.dec(vGATEWAY[1]) |
|
700 |
PST.dec(vGATEWAY[1]) |
459 |
PST.Str(string(".")) |
|
701 |
PST.Str(string(".")) |
460 |
PST.dec(vGATEWAY[2]) |
|
702 |
PST.dec(vGATEWAY[2]) |
461 |
PST.Str(string(".")) |
|
703 |
PST.Str(string(".")) |
462 |
PST.dec(vGATEWAY[3]) |
|
704 |
PST.dec(vGATEWAY[3]) |
463 |
PST.Str(string(PST#NL)) |
|
705 |
PST.Str(string(PST#NL)) |
464 |
PST.Str(string(PST#NL)) |
|
706 |
PST.Str(string(PST#NL)) |
465 |
|
|
707 |
|
466 |
return 'end of SetVerifyGateway |
|
708 |
return 'end of SetVerifyGateway |
467 |
|
|
709 |
|
468 |
'*************************************** |
|
710 |
'*************************************** |
469 |
PRI SetVerifySubnet(_firstOctet) |
|
711 |
PRI SetVerifySubnet(_firstOctet) |
470 |
'*************************************** |
|
712 |
'*************************************** |
471 |
|
|
713 |
|
472 |
'Set the Subnet address and display it in the terminal |
|
714 |
'Set the Subnet address and display it in the terminal |
473 |
ETHERNET.WriteSubnetMask(true, _firstOctet) |
|
715 |
ETHERNET.WriteSubnetMask(true, _firstOctet) |
474 |
|
|
716 |
|
475 |
PST.Str(string(" Set Subnet......")) |
|
717 |
PST.Str(string(" Set Subnet......")) |
476 |
PST.dec(byte[_firstOctet + 0]) |
|
718 |
PST.dec(byte[_firstOctet + 0]) |
477 |
PST.Str(string(".")) |
|
719 |
PST.Str(string(".")) |
478 |
PST.dec(byte[_firstOctet + 1]) |
|
720 |
PST.dec(byte[_firstOctet + 1]) |
479 |
PST.Str(string(".")) |
|
721 |
PST.Str(string(".")) |
480 |
PST.dec(byte[_firstOctet + 2]) |
|
722 |
PST.dec(byte[_firstOctet + 2]) |
481 |
PST.Str(string(".")) |
|
723 |
PST.Str(string(".")) |
482 |
PST.dec(byte[_firstOctet + 3]) |
|
724 |
PST.dec(byte[_firstOctet + 3]) |
483 |
PST.Str(string(PST#NL)) |
|
725 |
PST.Str(string(PST#NL)) |
484 |
|
|
726 |
|
485 |
'Wait a moment |
|
727 |
'Wait a moment |
486 |
PauseMSec(500) |
|
728 |
PauseMSec(500) |
487 |
|
|
729 |
|
488 |
ETHERNET.ReadSubnetMask(@vSUBNET[0]) |
|
730 |
ETHERNET.ReadSubnetMask(@vSUBNET[0]) |
489 |
|
|
731 |
|
490 |
PST.Str(string(" Verified Subnet...")) |
|
732 |
PST.Str(string(" Verified Subnet...")) |
491 |
PST.dec(vSUBNET[0]) |
|
733 |
PST.dec(vSUBNET[0]) |
492 |
PST.Str(string(".")) |
|
734 |
PST.Str(string(".")) |
493 |
PST.dec(vSUBNET[1]) |
|
735 |
PST.dec(vSUBNET[1]) |
494 |
PST.Str(string(".")) |
|
736 |
PST.Str(string(".")) |
495 |
PST.dec(vSUBNET[2]) |
|
737 |
PST.dec(vSUBNET[2]) |
496 |
PST.Str(string(".")) |
|
738 |
PST.Str(string(".")) |
497 |
PST.dec(vSUBNET[3]) |
|
739 |
PST.dec(vSUBNET[3]) |
498 |
PST.Str(string(PST#NL)) |
|
740 |
PST.Str(string(PST#NL)) |
499 |
PST.Str(string(PST#NL)) |
|
741 |
PST.Str(string(PST#NL)) |
500 |
|
|
742 |
|
501 |
return 'end of SetVerifySubnet |
|
743 |
return 'end of SetVerifySubnet |
502 |
|
|
744 |
|
503 |
'*************************************** |
|
745 |
'*************************************** |
504 |
PRI SetVerifyIP(_firstOctet) |
|
746 |
PRI SetVerifyIP(_firstOctet) |
505 |
'*************************************** |
|
747 |
'*************************************** |
506 |
|
|
748 |
|
507 |
'Set the IP address and display it in the terminal |
|
749 |
'Set the IP address and display it in the terminal |
508 |
ETHERNET.WriteIPAddress(true, _firstOctet) |
|
750 |
ETHERNET.WriteIPAddress(true, _firstOctet) |
509 |
|
|
751 |
|
510 |
PST.Str(string(" Set IP..........")) |
|
752 |
PST.Str(string(" Set IP..........")) |
511 |
PST.dec(byte[_firstOctet + 0]) |
|
753 |
PST.dec(byte[_firstOctet + 0]) |
512 |
PST.Str(string(".")) |
|
754 |
PST.Str(string(".")) |
513 |
PST.dec(byte[_firstOctet + 1]) |
|
755 |
PST.dec(byte[_firstOctet + 1]) |
514 |
PST.Str(string(".")) |
|
756 |
PST.Str(string(".")) |
515 |
PST.dec(byte[_firstOctet + 2]) |
|
757 |
PST.dec(byte[_firstOctet + 2]) |
516 |
PST.Str(string(".")) |
|
758 |
PST.Str(string(".")) |
517 |
PST.dec(byte[_firstOctet + 3]) |
|
759 |
PST.dec(byte[_firstOctet + 3]) |
518 |
PST.Str(string(PST#NL)) |
|
760 |
PST.Str(string(PST#NL)) |
519 |
|
|
761 |
|
520 |
'Wait a moment |
|
762 |
'Wait a moment |
521 |
PauseMSec(500) |
|
763 |
PauseMSec(500) |
522 |
|
|
764 |
|
523 |
ETHERNET.ReadIPAddress(@vIP[0]) |
|
765 |
ETHERNET.ReadIPAddress(@vIP[0]) |
524 |
|
|
766 |
|
525 |
PST.Str(string(" Verified IP.......")) |
|
767 |
PST.Str(string(" Verified IP.......")) |
526 |
PST.dec(vIP[0]) |
|
768 |
PST.dec(vIP[0]) |
527 |
PST.Str(string(".")) |
|
769 |
PST.Str(string(".")) |
528 |
PST.dec(vIP[1]) |
|
770 |
PST.dec(vIP[1]) |
529 |
PST.Str(string(".")) |
|
771 |
PST.Str(string(".")) |
530 |
PST.dec(vIP[2]) |
|
772 |
PST.dec(vIP[2]) |
531 |
PST.Str(string(".")) |
|
773 |
PST.Str(string(".")) |
532 |
PST.dec(vIP[3]) |
|
774 |
PST.dec(vIP[3]) |
533 |
PST.Str(string(PST#NL)) |
|
775 |
PST.Str(string(PST#NL)) |
534 |
PST.Str(string(PST#NL)) |
|
776 |
PST.Str(string(PST#NL)) |
535 |
|
|
777 |
|
536 |
return 'end of SetVerifyIP |
|
778 |
return 'end of SetVerifyIP |
537 |
|
|
779 |
|
538 |
'*************************************** |
|
780 |
'*************************************** |
|
|
<> |
781 |
PRI StringSend(_socket, _dataPtr) |
|
|
|
782 |
'*************************************** |
|
|
|
783 |
|
|
|
|
784 |
ETHERNET.txTCP(0, _dataPtr, strsize(_dataPtr)) |
|
|
|
785 |
|
|
|
|
786 |
return 'end of StringSend |
|
|
|
787 |
|
|
|
|
788 |
'*************************************** |
539 |
PRI OpenSocketAgain |
= |
789 |
PRI OpenSocketAgain |
540 |
'*************************************** |
|
790 |
'*************************************** |
541 |
|
|
791 |
|
542 |
ETHERNET.SocketOpen(0, ETHERNET#_TCPPROTO, socket, socket, @destIP[0]) |
<> |
792 |
ETHERNET.SocketOpen(0, ETHERNET#_TCPPROTO, localSocket, destSocket, @destIP[0]) |
543 |
ETHERNET.SocketTCPlisten(0) |
= |
793 |
ETHERNET.SocketTCPlisten(0) |
544 |
|
|
794 |
|
545 |
return 'end of OpenSocketAgain |
|
795 |
return 'end of OpenSocketAgain |
546 |
|
|
796 |
|
547 |
'*************************************** |
|
797 |
'*************************************** |
548 |
PRI PauseMSec(Duration) |
|
798 |
PRI PauseMSec(Duration) |
549 |
'*************************************** |
|
799 |
'*************************************** |
550 |
'' Pause execution for specified milliseconds. |
|
800 |
'' Pause execution for specified milliseconds. |
551 |
'' This routine is based on the set clock frequency. |
|
801 |
'' This routine is based on the set clock frequency. |
552 |
'' |
|
802 |
'' |
553 |
'' params: Duration = number of milliseconds to delay |
|
803 |
'' params: Duration = number of milliseconds to delay |
554 |
'' return: none |
|
804 |
'' return: none |
555 |
|
|
805 |
|
556 |
waitcnt(((clkfreq / 1_000 * Duration - 3932) #> 381) + cnt) |
|
806 |
waitcnt(((clkfreq / 1_000 * Duration - 3932) #> 381) + cnt) |
557 |
|
|
807 |
|
558 |
return 'end of PauseMSec |
|
808 |
return 'end of PauseMSec |
559 |
|
|
809 |
|
560 |
'*************************************** |
|
810 |
'*************************************** |
561 |
DAT |
|
811 |
DAT |
562 |
'*************************************** |
|
812 |
'*************************************** |
563 |
|
|
813 |
|
564 |
{{ |
|
814 |
{{ |
565 |
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ |
|
815 |
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ |
566 |
│ TERMS OF USE: MIT License │ |
|
816 |
│ TERMS OF USE: MIT License │ |
567 |
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ |
|
817 |
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ |
568 |
│Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │ |
|
818 |
│Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │ |
569 |
│files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │ |
|
819 |
│files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │ |
570 |
│modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│ |
|
820 |
│modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│ |
571 |
│is furnished to do so, subject to the following conditions: │ |
|
821 |
│is furnished to do so, subject to the following conditions: │ |
572 |
│ │ |
|
822 |
│ │ |
573 |
│The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│ |
|
823 |
│The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│ |
574 |
│ │ |
|
824 |
│ │ |
575 |
│THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │ |
|
825 |
│THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │ |
576 |
│WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │ |
|
826 |
│WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │ |
577 |
│COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ |
|
827 |
│COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ |
578 |
│ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ |
|
828 |
│ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ |
579 |
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
|
829 |
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
580 |
}} |
|
830 |
}} |