PDA

View Full Version : Hserin with Array



JKaiser
- 11th December 2014, 02:04
I am taking in data with Hserin and want to start keeping the data after I see "OK" and then stop after I get "HTTP". Is there any way to make the variable "hits" a array with unknown length. I know how to make it a large fixed array ( str test8/144) but does not seem to work between two waits. Can someone tell me if this is possible




dummy VAR BYTE
Hits VAR BYTE
test8 VAR BYTE[144]

Main:
HSERIN[WAIT ("OK"), Hits, WAIT ("HTTP"), DUMMY]
HSEROUT [hex Hits,13] ' Debug
GoTo Main

richard
- 11th December 2014, 05:42
Is there any way to make the variable "hits" a array with unknown length
no the array must be a predefined size, although you can stop filling it when an optional character is encountered




hserin [WAIT ("OK"),STR Hits\n{\c}]
Receive string of n characters
optionally ended in character

if c was to be 58 the var hits would fill until full or a : (chr58) is encountered

anything more would require your own routine

JKaiser
- 11th December 2014, 17:29
Thanks Richard,

I went ahead and set the array a little larger than I needed.



dummy VAR BYTE
Hits VAR BYTE
test8 VAR BYTE[44]
ESP1 VAR BYTE[2]
ESP2 VAR BYTE[2]

Main:
HSERIN[WAIT ("GET"), str test8\44] ', WAIT ("GET") and load data
hserout [str test8\44, 13, 13]
arrayread test8, 43, mAIN,[wait ("ESP1="), STR esp1\2]
arrayread test8, 43, mAIN,[wait ("ESP2="), STR esp2\2]
hserout ["ESP1=", STR esp1\2, 13]
hserout ["ESP2=", STR esp2\2, 13]

GoTo Main

Demon
- 11th December 2014, 18:46
Byte banging. :-)

I'd test using only one byte instead of array. I'd Hserin wait for start character, process byte (could be moving into 256 byte array, increment bytes found counter), Hserin byte, goto process byte until receive end character, process array, start over.

Start-end can be anything you won't usually receive #$%&*+<>~|√π§Δ£¢€¥^°±{}/\!¡©®™℅[]¿?().

Hserin one byte multiple times might be more efficient than always receiving a large array, or it might not.

Robert

JKaiser
- 11th December 2014, 19:13
Robert,

I started off in that direction but ended up confused in the loop trying to pull out parts of the array (GET /?ESP1=R1&ESP2=R2&ESPx=%25 HTTP/1.1) and separate the parts for ESP1 and ESP2 vars. I will definitely revisit it before moving to far forward.

John