Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"The semaphore timeout period has expired" error for USB connection

I'm getting this error...

The semaphore timeout period has expired.

On this line...

ThePorts.ActivePort1.Open();

...but I only get it from time to time. When it happens, it happens over and over again. Then the problem goes away, for hours or days, then it comes back.

The serial port is a USB with a BlueTooth connected.

I think this guy was having a very similar problem, but not in C#

Freeze on SerialPort.Open / DeviceIoControl / GetcommState with usbser.sys

As best I can estimate, I have read his entire problem, and the resulting comments, and the answer, but I really can't figure out which one fixed his problem, or if C# is significantly different from what he was experiencing.

Thanks for any help for the clueless. This is the actual code where it's happening.

public static void Open_ActivePortWeWillUse(String Drone_StringNameFromUser)
{
    SerialPort TempSerialPort = new SerialPort(Drone_StringNameFromUser, (int) SerialPortSpeed);

    ThePorts.ActivePort1 = TempSerialPort;

    ThePorts.ActivePort1.DataBits = 8;
    ThePorts.ActivePort1.Parity = Parity.None;
    ThePorts.ActivePort1.StopBits = StopBits.One;

    ThePorts.ActivePort1.DataReceived += new SerialDataReceivedEventHandler(OurBackGroundSerialPortReceiver);

    ThePorts.ActivePort1.Open();  // "Sometimes" Error hits here
}
like image 469
User.1 Avatar asked Dec 22 '12 02:12

User.1


People also ask

What causes the semaphore timeout period has expired?

The "semaphore timeout period has expired" message occurs when your system fails to transfer files from the source drive to the destination drive due to reasons like failure to connect establishment and inability to locate the source or target.

How do you fix Diskpart has encountered an error the semaphore timeout period has expired see the system event log for more information?

Solution 1: Use CHKDSK to Check and Repair Bad Sectors & Disk Errors. Solution 2: Run System File Checker to Repair Missing or Corrupted System Files. Solution 3: Temporarily Disable Antivirus and Firewall. Solution 4: Update Wireless network adapters.

What is error 0x80070079 The semaphore timeout period has expired?

The main reason for this error 0x80070079 is the problem of your network connection. And network problem is always blamed on its driver. In such case, try to update your network adapter driver to fix the error.


3 Answers

Okay, I am now connecting without the semaphore timeout problem.

If anyone reading ever encounters the same thing, I hope that this procedure works for you; but no promises; hey, it's windows.

In my case this was Windows 7

I got a little hint from This page on eHow; not sure if that might help anyone or not.

So anyway, this was the simple twenty three step procedure that worked for me

  • Click on start button

  • Choose Control Panel

  • From Control Panel, choose Device Manger

  • From Device Manager, choose Universal Serial Bus Controllers

  • From Universal Serial Bus Controllers, click the little sideways triangle

  • I cannot predict what you'll see on your computer, but on mine I get a long drop-down list

  • Begin the investigation to figure out which one of these members of this list is the culprit...

    • On each member of the drop-down list, right-click on the name

    • A list will open, choose Properties

    • Guesswork time: using the various tabs near the top of the resulting window which opens, make a guess if this is the USB adapter driver which is choking your stuff with semaphore timeouts

  • Once you have made the proper guess, then close the USB Root Hub Properties window (but leave the Device Manager window open).

  • Physically disonnect anything and everything from that USB hub.

  • Unplug it.

  • Return your mouse pointer to that USB Root Hub in the list which you identified earlier.

  • Right click again

  • Choose Uninstall

  • Let Windows do its thing

  • Wait a little while

  • Power Down the whole computer if you have the time; some say this is required. I think I got away without it.

  • Plug the USB hub back into a USB connector on the PC

  • If the list in the device manager blinks and does a few flash-bulbs, it's okay.

  • Plug the BlueTooth connector back into the USB hub

  • Let windows do its thing some more

  • Within two minutes, I had a working COM port again, no semaphore timeouts.

Hope it works for anyone else who may be having a similar problem.

like image 118
User.1 Avatar answered Oct 04 '22 22:10

User.1


This error could also appear if you are having network latency or internet or local network problems. Bridged connections that have a failing counterpart may be the culprit as well.

like image 42
Rudy Hinojosa Avatar answered Oct 04 '22 20:10

Rudy Hinojosa


I had this problem as well on two different Windows computers when communicating with a Arduino Leonardo. The reliable solution was:

  • Find the COM port in device manager and open the device properties.
  • Open the "Port Settings" tab, and click the advanced button.
  • There, uncheck the box "Use FIFO buffers (required 16550 compatible UART), and press OK.

Unfortunately, I don't know what this feature does, or how it affects this issue. After several PC restarts and a dozen device connection cycles, this is the only thing that reliably fixed the issue.

like image 34
Marcus10110 Avatar answered Oct 04 '22 20:10

Marcus10110