I have a remote serial device attached to
/dev/ttyAMA0 that requires a serial command to be issued before a program connects so that the program will read the return string and automatically recognize it. I can not change the behavior of the main program.
Is there any way to run a script when a userland program accesses a
/dev/tty character device?
udev rule only runs during boot and not, say when I connect with minicom.
I was researching a way to make a fake character device that would do this but it was looking like I would need to write a device driver.
/dev/ttyAMA0and another pseudo tty, and does whatever initialization is required first? Then the userland program can access the pseudo tty slave instead of
/dev/ttyAMA0. It's not hard to write such a program, look at