Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Serial communication #866

Open
pauliusbau opened this issue Feb 12, 2024 · 8 comments
Open

Problem with Serial communication #866

pauliusbau opened this issue Feb 12, 2024 · 8 comments
Labels
wontfix This will not be worked on

Comments

@pauliusbau
Copy link

Describe the bug
I am trying to control a custom Arduino device via Serial. COM ports are enumerated successfully, but App throws timeout messages every time it trys to send a message out (see below). I tired several different USB-Serial adapters and different COM port configurations.
I tried to reset settings. Tried to reinstall the app. No luck whatsoever. No Serial communication is getting through (sniffed serial bus with logic analyzer). Any ideas how to fix this issue?

Log messages:

"Timestamp":"2024-02-11T14:23:56.3271400+02:00",
"Level":"Error",
"MessageTemplate":"Error Performing Serial Write - LocalSerialHost:PerformSerialMessage Line: 278",
"Exception":"System.TimeoutException: The operation has timed out.\r\n at System.IO.Ports.SerialStream.Read(Byte[] array, Int32 offset, Int32 count, Int32 timeout)\r\n at System.IO.Ports.SerialStream.Read(Byte[] array, Int32 offset, Int32 count)\r\n at System.IO.Ports.SerialPort.InternalRead(Char[] buffer, Int32 offset, Int32 count, Int32 timeout, Boolean countMultiByteCharsAsOne)\r\n at System.IO.Ports.SerialPort.ReadTo(String value)\r\n at System.IO.Ports.SerialPort.ReadLine()\r\n at PresenceLight.Core.LocalSerialHostService.<>c__DisplayClass17_0.<PerformSerialMessage>b__0()",
"Properties":{
    "SourceContext":"PresenceLight.Core.LocalSerialHostService",
    "LineNumber":278,
    "FilePath":"D:\\a\\presencelight\\presencelight\\src\\PresenceLight.Core\\Lights\\LocalSerialHostService\\LocalSerialHost.cs",
    "MemberName":"PerformSerialMessage",
    "message":"Available\\n",
    "Application":"PresenceLight"}


"Timestamp":"2024-02-11T14:23:56.3286543+02:00",
"Level":"Information",
"MessageTemplate":"Sending Available\\n to COM3 - LocalSerialHost:PerformSerialMessage Line: 288",
"Properties":{
    "SourceContext":"PresenceLight.Core.LocalSerialHostService",
    "LineNumber":288,
    "FilePath":"D:\\a\\presencelight\\presencelight\\src\\PresenceLight.Core\\Lights\\LocalSerialHostService\\LocalSerialHost.cs",
    "MemberName":"PerformSerialMessage",
    "message":"Available\\n",
    "Application":"PresenceLight" }

Further details

  • OS: Windows 11 (no admin rights)
  • PresenceLight App Type: AppPackage
  • PresenceLight Version 5.8.2
  • Did you clear settings.json? (C:\Users\username\AppData\Local\Packages\37828IsaacLevin.197278F15330A.SomeValue\LocalState\settings.json: Yes, didn't help :(
  • ASP.NET Core version: 5.0.17
@isaacrlevin
Copy link
Owner

hey @pauliusbau, sadly I did not add this feature and don't have the HW to test. Possibly @JMilthaler can help as he did the work on this.
FWIW did this ever work for you? The code hasn't been touched in 1 years :O

@pauliusbau
Copy link
Author

Hey. No, it haven't. It's the first time I am trying it out.

@isaacrlevin
Copy link
Owner

Hmmm yea, unless something changed in System.IO.Ports I am not sure what the issue, unless you have the ability to clone the repo and test locally?

@JMilthaler
Copy link
Contributor

JMilthaler commented Feb 21, 2024

It's been quite a long time since I looked at this code, so it may take a bit to reacquaint myself with the details, but I can also look. I don't remember if the settings.json file has any sensitive information in it. If not, having a copy of that may help me see what's going on.

I do also have a very simple example of an Arduino based serial communication in my repo - https://github.com/JMilthaler/PresenceLightHardware/tree/master/PresenceLight.Hardware.Serial

** edit **
Ignore PresenceLight.Hardware.BLE in that repo - the hardware was never reliable and often stopped working randomly

@isaacrlevin
Copy link
Owner

The only thing you need to add is the client ID in appsettings.json.

Send me an email [email protected] and I will send it to you

@JakeShirley
Copy link
Contributor

I am also seeing something similar. My serial connections work fine for a day or two, but then I start getting these errors:
System.IO.IOException: The semaphore timeout period has expired. : 'COM3' and serial commands fail to send.

@isaacrlevin
Copy link
Owner

sadly I do not have a device to test this feature. More than happy to review a PR if you have a fix

@isaacrlevin isaacrlevin added wontfix This will not be worked on and removed Need User Test labels May 23, 2024
@JMilthaler
Copy link
Contributor

I am also seeing something similar. My serial connections work fine for a day or two, but then I start getting these errors: System.IO.IOException: The semaphore timeout period has expired. : 'COM3' and serial commands fail to send.

I think this happens when the serial device goes to sleep or loses power. I can only speak to the Seeduino XIAO because that's what I used, but I had to disable all power saving functions on the device or I received similar issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants