-
Notifications
You must be signed in to change notification settings - Fork 592
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
hs.serial does not appear to receive serial data correctly #3310
Comments
Just reloading now, here are the Hammerspoon logs for this file. I switched apps a few times and pressed the button a few times:
And here is in the PlatformIO serial terminal sending
|
Ummm... that's strange. I use Have you tried setting the hs.serial:dataBits() and hs.serial:stopBits()? Maybe the default values aren't suitable for your application>?
hammerspoon/extensions/serial/libserial.m Line 878 in 1bd0c18
hammerspoon/extensions/serial/libserial.m Line 904 in 1bd0c18
|
Actually... this is most likely your issue: |
You could try adding: self.serialPort.RTS = YES;
self.serialPort.DTR = YES; ...here: hammerspoon/extensions/serial/libserial.m Line 411 in 1bd0c18
|
@latenitefilms should we just expose those through hs.serial's API? |
Yes, I think so. I'm not entirely sure how best to document, as it's not really well documented in the pod's repo - but I'll try do a pull request later today. |
@latenitefilms I would just document them as "control flow signals" - there is tons of info online about what RTS, DTR, CTS, etc. mean, they are very generic serial communication signals. |
I understand what they are, what I don't quite have my head around is how |
@latenitefilms interesting find, yeah, that sounds exactly like the issue I'm having. It does seem to be a limitation of the microcontroller itself that requires RTS and DTR to be enabled. I did find that when I disabled both RTS and DTR that's when it wouldn't communicate correctly. Below is a session I just ran, starting with a new serial monitor, defaulting to both on. The messages between dashes are from the monitor itself, using the control commands to toggle flow control on and off. At each toggle, I would send a
|
- Added methods to get and set the `RTS` and `DTR` values. - Fixed some inconsistencies in the documentation. - Fixed some typos where `LS_TNUMBER` was incorrectly used instead of `LS_TBOOLEAN`. - Closes Hammerspoon#3310
@sethvoltz - I've added a pull request which will HOPEFULLY resolve the issue you're having. |
@latenitefilms Thank you! I can't wait to get it in the auto update. I'll report back here if it doesn't resolve the issue. |
I am working on a custom Arduino-based macropad that takes status from Hammerspoon to update indicators and commands from the pad to update apps via Hammerspoon integrations and spoons. I am able to send serial data to the device but no messages are passed back to the callback. My setup is as follows:
The setup:
On the hardware side, I have a 32u4-based development board (Adafruit Itsy-Bitsy, 5V) with a test sketch that does a few things: reads serial and looks for "set" if that is followed by "on", it blinks the LED fast, otherwise it blinks it slowly. On switching, it prints back whether it was set fast or slow. It also has a button input that prints "button pressed".
On the Hammerspoon side, I have a simple setup that creates the serial port (hard coded path for testing), attaches a callback, and opens the port. It then attaches an app handler to look for when Hammerspoon is brought to the front to test serial recept bt the hardware. Lastly, it also has a timeout to close the port after 20 seconds so I don't need to quit Hammerspoon while testing in order to re-flash and use the other serial monitors.
What happens:
When I bring Hammerspoon console to the front, the LED blinks fast, when I switch to another app, it blinks slowly, indicating the remote hardware is receiving serial successfully. No messages are logged back or when I press the button.
What I expect to happen:
Whenever the apps switch, I expect to see a serial message logged. Whenever the button is pressed, I expect to see a serial message logged.
Control:
The serial messages work bidirectionally in all other serial consoles I have used.
Here is the complete Hammerspoon code:
The text was updated successfully, but these errors were encountered: