How to enable/disable a serial port?

1,239

I suppose that Java gnu.io.CommPortIdentifier will have bigger problems if you delete /dev/ttySx aftes disabling the serial port.

When yoou need to enable it again you must first create the node with MAKEDEV script or mknod command. Here is some info about creating serial devices.

Share:
1,239

Related videos on Youtube

surbob
Author by

surbob

Updated on September 18, 2022

Comments

  • surbob
    surbob over 1 year

    net MVC4 apps. How can I generate video file in my asp.net mvc4 application. I have collection of URLs that are sequence of images in base64 format, generated from canvas output. Please suggest me controller code.

  • MarcioB
    MarcioB almost 10 years
    I don't think this is the best approach... I need to emulate a situation where "the cable connecting in the port has fallen", and deleting the port wouldn't be the same, would it?
  • LHristov
    LHristov almost 10 years
    Always glad to learn new info. Well, disabling a port is not the best approach also. Why don't you just unplug the cable and see what is happening?
  • MarcioB
    MarcioB almost 10 years
    Because it's supposed to be an automated test. And I did said what I was trying to do at the beginning of the question :)
  • LHristov
    LHristov almost 10 years
    For me disabled port is much different from enabled, but not connected port. I've worked with serial ports under Windows and there disabled port is something you cannot use; enabled port with broken link is something you can open from the app and can send data, and can wait forever for answer (forever = timeout in my case). If you want to do automated test better think about hardware disabling/enabling e.g. to connect 2 serial ports through 3wired cable, put a relay on TX wire and disable and enable it programmatically, through timer or by any other way.
  • MarcioB
    MarcioB almost 10 years
    I thought that a disabled port was the closest I could get from an unconnected one, thanks for the info. Anyway, the hardware option you described is not available to me, do you see any other alternative?
  • LHristov
    LHristov almost 10 years
    Yes, build a retranslator. A simple program that listens to ttyS0 and transmit everything to ttyS1 and back. And your connection will be A-B=C-D, where B and C is the retranslator and A and D is the tested software/hardware. And periodically stop retransmitting - that is the 'cable' problem. This can be done on one pc with 4 serial ports or 2 pcs.
  • MarcioB
    MarcioB almost 10 years
    I've got your idea, but I don't know how to implement it. Give me a few days and I will update my question (or post an answer) with your sugestion. Thank you.