I wonder if it is possible to fake a serial device so i can run some tests locally.
I need to write a little application which is communicating trough a serial connection with an arduino. But i don't have access to an arduino all the time. So i want to fake this connection.
I know it is possible with pipes, but i want to use the serial classes i have to use in the project later on.
(python-pyserial) tried using it with a fifo... doesen't work.
Would be nice if i could define the baude rate and stuff. It doesn't matter if the fake device does not actualli use that value but the code should be as complete as possible when i'm done.
I found this example but it does not seem to be what i need.
socat PTY,link=$HOME/COM1 PTY,link=$HOME/COM2
Last edited by Archdove (2013-03-21 14:55:38)
With all due respect, I think you are wrong. socat is probably exactly what you are looking for. It has been a while since I have used the tools, so I cannot offer suggestions of the top of my head, but look into the documenation of socat,; also goggle the terms 'linux pts ptmx'
Using these tools, you will be able to create a device node which your application can open, and treat as a file -- you can stream to and from it. ioctl calls could be a problem for things such as Baud and character format. The magic is that the tools create a second device node that can be opened by other programs, such as a serial terminal emulator (minicom, gtkterm).
Super double bonus points if you can run your Arduino code in an emulator; an emulator that maps the Arduino serial port to one end of the pts/ptm pipes. Believe it or not, in that configuration, it may even be possible to attach a debugger to the emulator and use the power of the debugger to analyze your target code. But I digress,
Last edited by ewaller (2013-03-21 15:11:11)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
You assume people are rational and influenced by evidence. You must not work with the public much. -- Trilby
How to Ask Questions the Smart Way
Yes it does work