How to start term session on serN at runtime without tinit?

How can I start a term session on ser2 at runtime without tinit?

Conversely, how does ‘tinit’ do what is does? How does it run an executable in the ‘ttys’ file (e.g. ‘login’) with the stdin/out/err redirected to the device specified in the ‘ttys’ file (e.g. /dev/ser2)?

I want to do this without using ‘tinit’. I want to start a terminal session on a free serial port, at runtime, and, specifically, not at system startup/boot.

I am running 6.4.0 on an x86 Vortex86sx cpu. I am having no other OS or serial port issues. Our app runs fine and will ship soon. This question concerns a possible field diagnostic/maintenance feature.

My goal seems reasonable (doing it w/o tinit), as this is routinely done in a boot script without tinit:

reopen /dev/ser2 echo Starting session on /dev/ser2... [+session] /bin/login &

The ‘[+session]’ part is not valid in a shell script, so if I do the following in a shell script (at run time):

reopen /dev/ser2 echo Starting session on /dev/ser2... /bin/login &

then on my terminal emulator (Windows hyperterm, or similar) I get the text ‘Starting session on /dev/ser2…’, and a ‘login:’ prompt, but nothing after that (no stdin redirection?).

According to the 6.3.0 ‘sample buildfiles’ documentation,

It sounds like that is what is missing when I try to use reopen/‘exec cmd’ in a shell script at runtime.

What am I missing? Is it an ‘stty’ flag that magically makes ser2 a “session leader”, or do I have to start my executable through something else (like ‘exec’) with some appropriate “session leader” flags? Or, am I just way off?

If you know the answer, read no further.

Otherwise…

Why don’t I just use ‘tinit’? Tinit does work if I add /dev/ser2 to the ‘ttys’ file (I get a session on ser2). But I don’t want the session at startup. I only want to use the serial port for system maintenance, in the field, when I tell my application to terminate (via another interface). The only serial port physically available on the product is used to implement a specific serial protocol (Modbus), so i can not leave a terminal session running on it all the time. I will send an undocumented ‘shutdown’ thru Modbus, then I will physically disconnect the Modbus wires from our product. When I connect my laptop serial port to our device, I want to have a terminal session waiting. After I do my maintenance, I can restart my app (and, preferably, kill the session), but re-booting the HW is also acceptable for now. I only want the terminal session when I want it, and when I have disconnected the customer’s Modbus wiring.

Furthermore, I find it hard to kill ‘tinit’, which I would have to do so I could restart ‘tinit’ with a modified/alternate ‘ttys’ file that include a ser2 entry. I may already have tinit running (for now) to handle other permanent session devices (con1, …), and I have found that a second tinit instance does not work, so I am back to killing, when necessary, the original instance. Some day, I don;t want any tinit running. Just one terminal session, where I want it (ser2), when I want it (when I kill my app).

Thanks[/i]

on -t /dev/ser1 sh or on -t /dev/ser1 login should do it.

Thanks Mario.

Your suggestion worked perfectly!

It even looks like many of my earlier, but much less elegant, solutions would have worked, too, had I not used Windows Hyperterm (@#&^$%&) as part of my test. Usually I don’t.

Because I was using Hyperterm, it seems no approach will work (including your suggestion) without turning on the stty ‘onlcr’ flag (and opost) on the serial port (on the QNX side) before starting the terminal session. I don’t know why, but the answer is, as it often is, Don’t use Hyperterm!.

Thanks again.
‘on’ is definitely the solution I was looking for, even if I didn’t know what my problem was.

Peter