简体   繁体   中英

Com ports get stuck or stop sending serial communication after working for 7-8 hours

I am working on a project for sending hex data continuously to serial com ports from my computer and then from com ports to LEDs (RGB lights) through RS232 USB cable. Sometimes it works for 10 -15 hours and alternate days it gets stopped sending data to ports.

I am using DMX 512 controller, RS232 USB cable with FTDI driver and c# language for coding to send data with SerialPort class.

Here is my code:

public static GO () 
{
    try
    {
        dmx = new Dmx(2, 0);

        Thread mTh1 = new Thread(() => dmx.Start(RGBdata1, RGBdata2, RGBdata3)); 

        Global.tmrStarted = true;  // test it,ok

        mTh1.Start();
    }
}

This is my start method where I send data to 3 ports

while (Global.tmrStarted)
{
    Break();
    Thread.Sleep(500); 
    if (m_port == null || m_port.IsOpen == false) return;
    m_port.Write(new byte[] { 0 }, 0, 1);
    SendData();


    Break1();
    if (m_port1 == null || m_port1.IsOpen == false) return;
    m_port1.Write(new byte[] { 0 }, 0, 1);
    SendData1();
    Break2();

    if (m_port4 == null || m_port4.IsOpen == false) return;
    m_port4.Write(new byte[] { 0 }, 0, 1);
    SendData2();

    Thread.Sleep(100);
}

When it gets stopped i try to send data through click on start button but data doesn't gets sent through those com ports till i don't remove my USB cable and plug in again which works after that.

Can anyone suggest me what's real problem with communication ports.Did they get disable by sending continuously data to them .Thanks in advance

I had this problem also, After all my research, I was find that it happen only in USB to serial COM, because power saving of windows shut them off. See how configure it in the attached picture. 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM