Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
18 June, 2013, 08:11:57 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1] 2   Go Down
  Print  
Author Topic: TI netcat -  (Read 1026 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
christop
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 13 April, 2013, 04:04:55
Date Registered: 26 February, 2011, 19:58:44
Location: Arizona, USA
Posts: 87

Topic starter
Total Post Ratings: +20

View Profile
« on: 16 August, 2012, 21:35:46 »
+3

(Cross-posted from cemetech for those who haven't seen it there)

I'm working on a project called "tinc", short for "TI netcat". My original plan was to write a program that can talk to a calculator and can either connect or listen for connections over the network. The current incarnation doesn't speak over the network but rather only over stdin/stdout, but it can still speak over the network with the help of nc (or perhaps even inetd). If I decide not to add networking functionality to tinc, I'll probably rename the project to "ticat".

I've been working with Lionel Debroux and Benjamin Moody to make it work with ticables reliably. Now it's at a point where it should be pretty stable (but it's still not ready for a real release yet). I've only tested it with TiEmu and Punix (not that the OS should make a difference).

Get tinc here: https://github.com/abbrev/tinc

Anyway, here's a little networked tinc demo (using nc for the network part):

1
2
$ mkfifo pipe
$ <pipe nc -l 8002 | ./tinc -c tiemu >pipe
In Punix on the calculator (TiEmu) I ran the "uterm" program, which  is a terminal program that talks over the link port (kind of like minicom in *nix or Hyperterminal in Windows). Then I browsed to http://localhost:8002/ in Firefox.

In the following screenshot, the first 9 lines (11 lines with line wrapping) starting at "GET / HTTP/1.1" are the HTTP request from Firefox. The next 6 lines (starting at "HTTP/1.1 200") are the HTTP reply that I manually typed on the calculator. Firefox displayed the text "Hello world!" in plain text as soon as I hit enter on the last line. Hooray for an impractical web server. Smiley




Another use for tinc is to use the Punix shell from a real terminal. This works only if Punix is listening for logins over the link port, which is not the case with the demo above (the link port can be opened only once at a time in Punix).

Anyway, here's a short run using the Punix shell in my Linux terminal:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ ./tinc -c tiemu

server login: root
password:
stupid shell v0.2
root@server:~# help
available applets:
 tests     top       cat       echo      true      false     clear     uname
 env       id        pause     batt      date      adjtime   malloc    pid
 pgrp      poweroff  times     sysctltest ps        bt        crash     mul
 div       kill      time      exit      status    help
root@server:~# echo hello world!
hello world!
root@server:~# exit

server login:
This was actually my first use of tinc, but I think the HTTP demo is more impressive. Smiley

I hope I can get tinc ready for release before too long, and I hope we all can find useful and innovative uses for tinc. I already thought about writing a VNC server for Punix as a sort of replacement for the TI screenshot functionality. Who knows what else we can come up with?
Logged

Christopher Williams
Jim Bauwens
Lua! Nspire! Linux!
Editor
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 00:06:13
Date Registered: 28 February, 2011, 22:32:12
Location: Belgium
Posts: 1736


Total Post Ratings: +180

View Profile WWW
« Reply #1 on: 16 August, 2012, 23:50:04 »
0

Nice, awesome job!!
What about an irc client ? The protocol isnt that complex Cheesy
Logged

AzNg0d1030
LV6 Super Member (Next: 500)
******
Offline Offline

Gender: Male
Last Login: 06 June, 2013, 19:33:43
Date Registered: 26 October, 2011, 04:43:09
Location: Over the rainbow
Posts: 489


Total Post Ratings: +37

View Profile
« Reply #2 on: 17 August, 2012, 03:30:06 »
0

Nice, awesome job!!
What about an irc client ? The protocol isnt that complex Cheesy
I thought someone already made one for Nspire Huh?
Logged

What? WHAT? WHATTTT?Huh??

You just lost the game.

Suck it up.
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Online Online

Gender: Male
Last Login: Today at 08:11:34
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50599


Total Post Ratings: +2634

View Profile WWW
« Reply #3 on: 17 August, 2012, 04:36:05 »
0

TI-netcat... so now we can plug a cat to our calculator to have Internet?? shocked

Just kidding I read the first post in overall. Sounds really great. I wonder if eventually there could be something like CALCnet but for 68K calcs?
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
christop
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 13 April, 2013, 04:04:55
Date Registered: 26 February, 2011, 19:58:44
Location: Arizona, USA
Posts: 87

Topic starter
Total Post Ratings: +20

View Profile
« Reply #4 on: 17 August, 2012, 05:42:32 »
0

Nice, awesome job!!
What about an irc client ? The protocol isnt that complex Cheesy
Thanks! I'd like to make one, but I have enough projects as it is, and my time is really limited right now. Maybe you could write a simple one in C that reads and writes to a pipe/socket/whatever and to stdin/stdout, and then I can port it to Punix. Note that the select() system call doesn't work yet, so you'll have to find another way to read from the socket/pipe and from stdin without blocking.

I thought someone already made one for Nspire Huh?
Someone probably did, but I'm working with a TI-92+. My primary OS on it is Punix, which makes it relatively easy to read and write to the link port. But tinc works with any calculator that uses the same low-level data protocol, which includes all of the TI-8x, TI-9x, and I'm sure the Nspire as well. What you do with the data that you read and write... well, that's up to you. Smiley

TI-netcat... so now we can plug a cat to our calculator to have Internet?? shocked

Just kidding I read the first post in overall. Sounds really great. I wonder if eventually there could be something like CALCnet but for 68K calcs?
I have some plans for making a similar protocol to CALCnet (called Chrisnet for now), but mine will be designed more for TCP/IP networking. globalCALCnet works by sending CALCnet frames over TCP using proxy server(s). With Chrisnet, it's the other way around: IP datagrams will be carried inside Chrisnet frames, much like IP is carried inside Ethernet frames. In fact, it will be similar to Ethernet in some ways. I also have ideas for building a hub to translate Chrisnet frames to Ethernet or SLIP or PPP frames, depending on the cost and complexity of parts needed to build one, so you can plug in your calculator and connect to the Internet over TCP/IP. I'm leaning toward SLIP or PPP since they are simpler and less expensive than Ethernet (which uses... CAT 5 cables! Tongue). But I haven't even made a proof-of-concept for my protocol, so I'm really putting the cart before the horse until I can demonstrate that my protocol works.

(And I actually haven't worked on hardly anything calculator-related for the last few months, up until about a week ago. My job and family keep me plenty busy.)
Logged

Christopher Williams
Jim Bauwens
Lua! Nspire! Linux!
Editor
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 00:06:13
Date Registered: 28 February, 2011, 22:32:12
Location: Belgium
Posts: 1736


Total Post Ratings: +180

View Profile WWW
« Reply #5 on: 17 August, 2012, 11:50:05 »
0

Thanks! I'd like to make one, but I have enough projects as it is, and my time is really limited right now. Maybe you could write a simple one in C that reads and writes to a pipe/socket/whatever and to stdin/stdout, and then I can port it to Punix. Note that the select() system call doesn't work yet, so you'll have to find another way to read from the socket/pipe and from stdin without blocking.

I could do it, but I don't have much experience with sockets/pipes/etc (in C), so I'll need to see.
What standard libs can I use in punix ?
« Last Edit: 17 August, 2012, 20:50:58 by Jim Bauwens » Logged

christop
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 13 April, 2013, 04:04:55
Date Registered: 26 February, 2011, 19:58:44
Location: Arizona, USA
Posts: 87

Topic starter
Total Post Ratings: +20

View Profile
« Reply #6 on: 17 August, 2012, 21:07:06 »
0

Thanks! I'd like to make one, but I have enough projects as it is, and my time is really limited right now. Maybe you could write a simple one in C that reads and writes to a pipe/socket/whatever and to stdin/stdout, and then I can port it to Punix. Note that the select() system call doesn't work yet, so you'll have to find another way to read from the socket/pipe and from stdin without blocking.

I could do it, but I don't have much experience with sockets/pipes/etc, so I'll need to see.
What standard libs can I use in punix ?

Only the C standard library and POSIX system interfaces. Even those are incomplete (such as the select() system call).

Here is an incomplete list of functions that work which I think you would need to write a simple IRC client:
  • open/close/read/write
  • printf/sprintf/fprintf
  • putc/putchar
  • getc/getchar
  • tolower/toupper/isalpha/isdigit/etc (all of ctype.h)
  • malloc/realloc/calloc/free
  • setitimer/getitimer
  • atoi/strtol
  • all str* and mem* (string.h) functions
  • signal/sigaction

The lack of select() is slightly annoying, but you can get around that by setting an interval timer (with setitimer()) to run every 100ms or so to interrupt read() calls on the link port and the terminal. This is what I did in the uterm program. That reminds me: I need to implement the O_NONBLOCK flag for file descriptors which would make read() and write() non-blocking. That shouldn't be too difficult, at least compared to select().
Logged

Christopher Williams
DWLooney
LV1 Newcomer (Next: 20)
*
Offline Offline

Last Login: 07 June, 2013, 02:14:16
Date Registered: 18 April, 2012, 04:09:59
Posts: 13

Total Post Ratings: 0

View Profile
« Reply #7 on: 18 August, 2012, 18:30:10 »
0

Wow, Iv'e always wanted to have internet on the nspire.

Do you think that the periphal used to connect the nspire to their special router could work? That would be awesome Big smile

This looks like a great project!
Logged
Lionel Debroux
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Today at 07:39:26
Date Registered: 17 December, 2009, 09:37:25
Location: France
Posts: 1915

Total Post Ratings: +215

View Profile WWW
« Reply #8 on: 21 August, 2012, 11:30:42 »
0

Doh, I've missed the topics on both Cemetech and Omnimaga. Now subscribed.

Quote
But tinc works with any calculator that uses the same low-level data protocol, which includes all of the TI-8x, TI-9x, and I'm sure the Nspire as well.
Nope, the Nspire doesn't have a proprietary 2.5mm stereo jack female plug Wink
The 84+ keyboard suitable for Clickpad/Touchpad models has one, but unless one is hot-switching the keyboards during a Ndless program that disables interrupts, the Nspire turns off when the standard keyboard is removed, and starts 84+ emulation mode when turned back on with the 84+ keyboard.
Logged

Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.
christop
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 13 April, 2013, 04:04:55
Date Registered: 26 February, 2011, 19:58:44
Location: Arizona, USA
Posts: 87

Topic starter
Total Post Ratings: +20

View Profile
« Reply #9 on: 21 August, 2012, 22:16:49 »
0

Quote
But tinc works with any calculator that uses the same low-level data protocol, which includes all of the TI-8x, TI-9x, and I'm sure the Nspire as well.
Nope, the Nspire doesn't have a proprietary 2.5mm stereo jack female plug Wink
The 84+ keyboard suitable for Clickpad/Touchpad models has one, but unless one is hot-switching the keyboards during a Ndless program that disables interrupts, the Nspire turns off when the standard keyboard is removed, and starts 84+ emulation mode when turned back on with the 84+ keyboard.
Ah, you are correct. What I should have said is "tinc works with any calculator that is supported by ticables", which also covers Direct USB on the models that support it.
Logged

Christopher Williams
christop
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 13 April, 2013, 04:04:55
Date Registered: 26 February, 2011, 19:58:44
Location: Arizona, USA
Posts: 87

Topic starter
Total Post Ratings: +20

View Profile
« Reply #10 on: 24 August, 2012, 03:43:47 »
0

Why was this moved to TI-68K Projects? It's a computer program that works with nearly all calculator models (I just happen to use it with Punix in my demos).

Can we get a new sub-forum for calculator-related computer programs?
Logged

Christopher Williams
Deep Thought
So much to do, so much time, so little motivation
Administrator
LV13 Extreme Addict (Next: 9001)
*
Offline Offline

Gender: Male
Last Login: Yesterday at 03:12:44
Date Registered: 19 May, 2009, 08:00:00
Location: The Universe
Posts: 7832


Total Post Ratings: +713

View Profile WWW
« Reply #11 on: 24 August, 2012, 23:12:06 »
0

Sorry, I took a look at the screenshot and assumed it was for the 68K series Tongue

EDIT: Now that I read the topic ... that is really awesome. One terribly impractical idea I've had for a while is to make a web server use TI-BASIC for a scripting language. Your little demo did it with an actual calculator Grin
« Last Edit: 24 August, 2012, 23:16:26 by Deep Thought » Logged




alberthrocks
Coder Of Tomorrow
LV8 Addict (Next: 1000)
*
Offline Offline

Last Login: 11 June, 2013, 19:34:32
Date Registered: 01 May, 2010, 16:51:27
Posts: 743

Total Post Ratings: +88

View Profile
« Reply #12 on: 26 August, 2012, 09:29:55 »
0

This is pretty amazing! I would be one very serious user** if you added TCP networking support! Cheesy
The Nspire (and friends) would appreciate some Internet connectivity. Wink

(For the Nspire, USB communication needs to be implemented Ndless side beforehand)

** By user, I don't mean just accessing the Internet, I also mean using it as a component for a major project! Wink
« Last Edit: 26 August, 2012, 09:30:20 by alberthrocks » Logged

Alternate "New" IRC post notification bot (Newy) down? Go here to reset it! http://withg.org/albert/cpuhero/

Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/

Activity remains limited due to busyness from school et al. Sorry! Sad Feel free to PM, email, or if you know me well enough, FB me if you have a question/concern. Smiley

Don't expect me to be online 24/7 until summer. Contact me via FB if you feel it's urgent.


Proud member of ClrHome!

Spoiler for "My Projects! :D":
Projects:

Computer/Web/IRC Projects:
C______c: 0% done (Doing planning and trying to not forget it Tongue)
A_____m: 40% done (Need to develop a sophisticated process queue, and a pretty web GUI)
AtomBot v3.0: 0% done (Planning stage, may do a litmus test of developer wants in the future)
IdeaFrenzy: 0% done (Planning and trying to not forget it Tongue)
wxWabbitemu: 40% done (NEED MOAR FEATURES Tongue)

Calculator Projects:
M__ C_____ (an A____ _____ clone): 0% done (Need to figure out physics and Axe)
C2I: 0% done (planning, checking the demand for it, and dreaming Tongue)
Lionel Debroux
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Today at 07:39:26
Date Registered: 17 December, 2009, 09:37:25
Location: France
Posts: 1915

Total Post Ratings: +215

View Profile WWW
« Reply #13 on: 26 August, 2012, 09:51:55 »
0

FWIW, there's already some TCP/IPv4 code for the TI-68k series, by Samir Ribic: http://www.ticalc.org/archives/news/articles/4/43/43965.html . I've just checked that it uses the OS routines (e.g. OSLinkReset and "transmit", which is an old name for an official routine), it doesn't do low-level linking by itself with a special protocol.

Being made in 2000, it's a pretty old-style TI-68k/AMS C program, though, and the accompanying instructions are similarly old.
Modern GCC4TI (with support for regparm and other stuff), and some code changes (a number of tricks I wrote in S1P9 apply, such as constifying char* arrays on the stack, or inlining trivial functions), would decrease the size. Old-style (K&R) function prototypes are not a problem wrt. optimization, but they're ugly by modern standards ^^
Logged

Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.
christop
LV3 Member (Next: 100)
***
Offline Offline

Gender: Male
Last Login: 13 April, 2013, 04:04:55
Date Registered: 26 February, 2011, 19:58:44
Location: Arizona, USA
Posts: 87

Topic starter
Total Post Ratings: +20

View Profile
« Reply #14 on: 30 August, 2012, 04:56:06 »
0

Let me clear up some possible misconceptions.

First, if I add networking to tinc, it won't do anything that the regular nc (netcat) doesn't already do. It'll be able to talk with only one other computer at a time, and you'll have to pick the IP or host name of the other computer when you run it (or put it in listen mode, then one other computer can connect and talk to the calculator). The calculator can't select the IP to connect to, and it can't know what IP connects to it.

Second, the calculator link protocol has no way to detect or signal an end-of-file condition or, by extension, to either close a network connection or detect when one has closed. In the HTTP demo I had to explicitly put the "Content-length" and "Connection: close" header in the response which told the browser when to close the connection. The calculator didn't know that tinc had exited when the browser closed the connection.

Third (and this is not just a tinc issue), the TI link protocol is only half-duplex, which means only one side can send a byte at a time. Normally this isn't a problem--the two sides can take turns talking at a fast enough rate that it isn't noticeable--but if both sides try to talk at the same time, there is a problem. It's a double problem because the protocol sometimes makes it difficult or impossible to distinguish between a "collision" and the other side simply not responding, so it's usually not possible to recover from it, leading to lost data. This happens a lot during interactive sessions, such as using the calculator as a terminal or a terminal server (I've done both with Punix Smiley). For example, if the computer is sending a lot of data (perhaps I cat a large file) and I try to type anything while it's sending data (say, Ctrl-C to kill cat), the outgoing data is likely to collide with the incoming data. There's nothing I can do with tinc to fix this problem, either. It's too bad TI didn't use a standard serial UART in their calculators as Casio did in theirs. (I am investigating adding a full-duplex "rs232" driver to Punix which will simulate a UART, but it will run at 2400bps at the very fastest.)

What Lionel mentioned (TCP/IP on the calculator) would fix the first two issues, but it's kind of heavy-weight for a calculator (but I would like to implement it in Punix anyway Smiley).

What tinc with networking (or used with nc) will let you do is simple point-to-point communication with another calculator anywhere across the globe, as long as you have network connectivity between them. Imagine playing a multi-player game with someone in another country! The game won't even have to use any special protocols like Kerm's CALCnet/globalCALCnet (which I admit are pretty neat protocols). The latency might kill in some types of programs (action games), but I'm sure it'll still be fun. Cheesy

Lionel: I've seen Samir's TCP/IP demo before, and I've also looked at TinyTCP (which his demo is based on) and other small TCP/IP stacks. My favorite at the moment is lwIP. It has a nice callback-driven API which looks like it might fit in well with the Punix kernel (the kernel would be lwIP's "application", and Punix already has timers, a memory allocator, and other necessities for lwIP to use).
Logged

Christopher Williams
Pages: [1] 2   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.368 seconds with 30 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.