I have a project that uses telnet (yes I know, but this is an embedded chip that is only connected to the PC)
with a standard terminal on Mac and win the whole system works as one might expect and I can do the job perfectly well, except I hate all that stupid command line typing.
therefore it came to mind I might try the shell in xojo to do the same but with nice push buttons and a great way to parse the received data.
I am aware shell is no terminal and it has limitations but I was not quite expecting it to do what it does do.
I have the path the telnet executable in my shell code thus:-
this works fine and opens the little chips tenet port and it sends back data, all good, but this is the data, received all at once in a few milliseconds without any more input from me:-
Connected to 192.168.0.100.
Escape character is ‘^]’.
Connection closed by foreign host.
the first three are from the little chip and is what I expect.
the connection closed is OS generated and is what happens on terminal when the little chip goes offline.
what happens in terminal is that after the third line it shows a small logon line of text and then prompts for user and password before allowing access to the little chip.
the code is super simple with no timers or any other code that is not solely to do with just the opening of the shell and executing the opening of the port.
anyone got any ideas about this? is it beyond the shell to do this, any other way to do this programatically?
Mac and win are the targets! xojo 19r1.1 API1 only.
Are you using mode 0, 1 or 2 for the shell?
that is rather a good question, I am actually not setting the mode at all.
so I will look at that right now, thanks for the thought, I will report back shortly.
Mode 0 stops your app until the shell closes. It closes the shell after running the command. Shell.Result will have the text from the shell operation.
Mode 1 & 2 keep the shell open, and you can use the DataAvailable event to see what it’s returning.
In these modes MAKE SURE to call Shell.Close or you can have a hanging shell that you’ll have to kill with Activity Monitor or a terminal command like KillAll…
yes, I am now getting some more reliable results so I think you pointed me on the correct path
thanks, I will report any success.
I managed to get this to do exactly what I wanted, thanks to the pointer from @Meestor_X
simply added a shell to a window
in the window open event set MODE=2
added the DataAvailble event to the shell and in it appended the READALL text to my text field, works great!
now to test on win to see if the issues detailed in the LR actually hold up.
Be warned telnet is on the list of no-longer approved terminal functions for macOS and may not be available on all machines.
yes I am aware of that, same for win too, which has it switched off by default so you have to turn the ‘feature’ on to get it running.
I installed in on my Mojave machine with homebrew as I could not find an old binary on any of the old junk Mac I have lying around.
I am not using it as a telnet interface per-se, rather as a way to connect a small embedded chip to a PC by a standard cable, serial is not an option for many reasons, I know ethernet plugs are on the way out in the Mac world, but sadly this will be a win only project (in the field) and the client has put that in his specification.
it is never ever going to be connected to any sort of network or exposed beyond the end of its ethernet cable.
also for information I am not using the telnet command structure in any way, in fact I rely on the commands I send to error so I can capture the data and parse it for my own use, basically using the telnet transport mechanism to work like it would if it were a serial port.
I used to use Telnet a lot for all kinds of things… I liked being able to fall back and do these things to the old fashioned way. I also liked that it was in the OS, you don’t have to use it if you don’t want to.
I guess we’re just getting too old…