0

I need to develop a test program, which sends and recieves data from terminal to the serial port.
In order to do that I want to create virtual device file and work with it. I did that by using command:

mknod -m 666 ttyS32 c 4, 500

The device file was successfully created, however I can't write data to it. Both programmatical and terminal ways give the following error:

No such device or address

In C I used standard file I/O functions, and in terminal I used the 'echo' command. Do you have any ideas how to write data to serial port device file?

mol
  • 2,607
  • 4
  • 21
  • 40

1 Answers1

1

That's right. You can write to the serial device using echo. Are you sure that the device (not the device file) exists and is properly handled by the driver?

Igor Chubin
  • 61,765
  • 13
  • 122
  • 144
  • Well, no. I have to mention, that I don't have device, I just want to make simple test program, which uses device file that simulates serial port. At the first step I don't need to consider special device settings, just general case. – mol Jul 10 '12 at 09:39
  • Ah, ok! that will not work of course! you must use only that devices that really exist or that are emulated. For example `/dev/tty1` or `/dev/pts/3` devices or something like that (of course it can be oter numbers here). Also note please that many serial port parameters, e.g. baudrate, parity, hw flow control, character size (?) are not implemented in pty and so when you want to play wit them you need to use real serial device. – Igor Chubin Jul 10 '12 at 09:44
  • Thanks, but that was the first thing I've done. There is an issue too. For example an attempt to write to /dev/ttyS1 gives an Input/output error. The same thing with others ttyS files. – mol Jul 10 '12 at 09:55
  • Are you sure that there real ttyS-ports in your system? – Igor Chubin Jul 10 '12 at 09:59
  • I didn't think about it :) I thought, that if there are device files, then they represent real devices, silly me. Works fine with ttyS0 device file, thanks for the help! – mol Jul 10 '12 at 10:08