I saw Matt's 40/80col telnet client yesterday and the thing works! Logged into my bbs via TIPI!
Sent from my LG-H872 using Tapatalk
I've added OEM 437 characters so some of the ANSI art makes sense. I'm working on processing the ANSI CSI codes now. I'll ignore color for now, but get the cursor controls in place.
This is working through a simple 'TiSocket' extension I added to the TIPI services. My Telnet client lives in the open source repo under examples/telnet, currently still on a branch named 'telnet'. This proves out the simple socket abstraction as being usable.
I described it to the closed beta group with this:
I've added a new low level API for TCP, described in the source:
# Represent socket access from Raw extensions. This is registered as 0x22 in RawExtensions.py
# usage: send a message starting with 0x22 as the first byte.
# second byte should be socket handle number to use
# third byte is command for handle: 0x01 open, 0x02 close, 0x03 write, 0x04 read
# For 0x01 open / follow with string in the form of "hostname:port"
# Tipi will return a message of 255 if connected or 0 if failed to connect.
# For 0x02 close / no parameters
# Tipi will return 255
# For 0x03 write / follow with bytes to write to socket
# Tipi will return after bytes are written with 255 or 0 if failed to write.
# For 0x04 read / follow with max size to read as int (two bytes, [msb,lsb])
# Tipi will return message of available socket data no greater than max size.
# socket handle numbers are a single byte 0-255
So, from C or assembly you can use the tipi DSR rom routines for sending messages or getting messages... and just have to adhere to this little byte header...
So, create a message like:
0x22, 0x00, 0x01, "www.cwfk.net:80" as a byte array.
Send it to TIPI with the routines or assembly equivalent in tipi_msg.c from the TIPI mouse demo code.
Read a response... again with the recv routine in tipi_msg.c. Now we have opened socket 0 as a connection to www.cwfk.net port 80.
Create a message to send data:
0x22, 0x00, 0x03, "GET / HTTP/1.1\n\n" as a byte array...
Send it to TIPI,
Now loop reading the response, until you think you've got it all... The read request would look like:
0x22, 0x00, 0x04, 0x04, 0x00 as a byte array... the last two bytes should be the max you want to read from the socket, in this case 1024 bytes (0x0400)
any extra data you don't read will block in the socket, and be waiting for you to loop back and see if you got what you need.
If nothing is available, you'll get a 0 length array back.
If the socket is closed already, you'll get a 1 byte array back with the value 0 in byte 0.
You can close the socket too...
0x22, 0x00, 0x02
Now we should be able to write TELNET, FTP, Browsers, Updated term emulators... and not have to worry about how slow the TI is...
Oh, and the original PI.TCP stuff is still there for Level 3 file io access if you want to do this from BASIC. It has a lot more overhead, so if you are coding in some lower level language, this new model will be much better.
And the messaging routines are called from C with the embedded assembly you see here: https://github.com/j...ouse/tipi_msg.c