serial-port | A set of C++ classes to easiliy handle serial ports | SDK library
kandi X-RAY | serial-port Summary
kandi X-RAY | serial-port Summary
A set of C++ classes to easiliy handle serial ports across different platforms, built on top of boost.asio.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of serial-port
serial-port Key Features
serial-port Examples and Code Snippets
Community Discussions
Trending Discussions on serial-port
QUESTION
I want to list the COM ports (like one can see in 'Device Manager'), but at runtime.
I shamelessly copied the code from this site (code shown at end of post), and I think I understand it. However, the program fails at line 36, giving me the error:
...ANSWER
Answered 2022-Feb-25 at 13:38Thank you to Simon Mourier and Ian Abbott!
As stated in the edit, calling RegOpenKeyEx
with _T("HARDWARE\\DEVICEMAP\\SERIALCOMM")
and casting szDeviceName
to a LPWSTR
fixed all errors.
Further, using the identifier %ls
in the call to _tprintf()
on line 92 made the names print correctly.
The final, working code looks like this:
QUESTION
I have a simple modbus device (Ebyte MA02-XACX0440) that I'm trying to learn how to work with. Using a third party GUI called serial port monitor (www.serial-port-monitor.org) I was able to more or less "stumble upon" the proper hexadecimal inputs needed to turn a discrete output on and then off. I don't understand these terms of unit, address, coils, registers, etc. and how it all relates when it comes to the hexadecimal aspect. To break down what I think I know so far (below is the hexadecimal string that will turn the first discrete output 'ON'):
0x20 0x05 0x00 0x00 0xFF 0x00 0x8A 0x8B
I know 0x20 is the device address in hex. The documentation of the Ebyte device stipulates that the default hardware address is '31' and that the first software address is '1'. If I understand that correctly, that means my first physical modbus device on the line has an address of '32', and if I were to put additional modbus devices on the line (either RS485 or TCP(?)) that the next device would be '33' and so on.
I know that the next byte 0x05 is 'write coil'.
I don't know what the next two bytes of '0x00' and '0x00' refer to.
The next two bytes are essentially on/off with '0xFF00' being 'ON' and 0x0000 being 'OFF'.
The final two bytes are simply the CRC checksum.
So up to this point I can get my DO (Discrete Output) to turn on, open up, and light up an LED as a simple proof of concept. Now when I take that approach over to using the pymodbus library (my ultimate goal), things don't seem to line up.
I am able to connect to my device using the pymodbus REPL using
...ANSWER
Answered 2022-Feb-10 at 20:06The Modbus specs describe the protocol and are worth a look. I use this online Modbus parser when I want to quickly parse a command; it's output for the string of bytes you give (20 05 00 00 FF 00 8A 8B
) is:
The slave address indicates which device on the bus you wish to communicate with. This is set on the device (you cannot just add devices and expect things to work). The method used to set slave ID's differs from device to device (some have a utility to do this, some use switches or settings via their own user interface, and some have this hard coded). Your device (Ebyte MA02-XACX0440) defaults to 32 but this can be changed using the DIP switch on the device (this is covered in the manual).
You are using function code 5 - 'Write Single Coil'. Coils are bits so can be on or off.
The 'output address' indicates which coil on the device you wish to write to. The meaning of this address varies from device to device (generally there will be a table in the documentation that explains this). For your device this is in table 7.1 ("Register list") in the manual.
The value is what to write. For the 'write single coil' function this must be one of two values:
value meaning 0x0000 Off 0xFF00 OnAll other values are invalid. However many libraries (incluing pymodbus) will handle this detail for you allowing you to pass True
/False
.
Putting this all together you will need something like:
QUESTION
I want to trigger an event whenever there is data to be read from a serial port while running a GUI. The pySerial
module apparently has experimental functionality for that, but it isn't particularly well documented (I couldn't find any useful examples in the API).
This question appears to deal with the same or at least very similar task, but doesn't provide instructions to replicate it or working code examples.
I came up with this code:
...ANSWER
Answered 2022-Jan-18 at 11:10Your main concern is to be thread safe, when You are updating GUI from another running Thread.
To achieve this, we can use .after() method, which executes callback for any given tk widget.
Another part of Your request is to use Threaded serial reader.
This can be achieved by using ReaderThread accompanied with Protocol.
You can pick two protocols:
- raw data reader protocol, which reads data as they come
- line reader protocol, which enables us to read lines of data
Here is working code example, with two protocols mentioned above, so You can pick which one suits You. Just remember, that all data coming from serial port are just raw bytes.
QUESTION
I am using gcloud commands to deploy simple VMs. I am using startup script to configure all the required packages on the machine. Our packages are fetched from nexus. Sometimes our changes or nexus network issues result in failure of startup script. I configured a block of code to validate startup script return code. I run gcloud create command and provide startup script, the code block to validate startup script output looks like this..
...ANSWER
Answered 2022-Jan-07 at 17:15Swallow standard error to avoid the extraneous output:
QUESTION
I just noticed that a new bucket has been created in my google cloud storage project. I have no idea why it is there or who created it. And, it takes up 2.6 GB!
If I execute gsutil du -h gs://PROJECT_NAME-daisy-bkt-us-central1
I get:
...ANSWER
Answered 2021-Sep-28 at 02:29I figured it out myself. Turns out, like John Hanley kindly pointed out, that I had imported a virtual machine. And I guess this bucket was created as part of that import.
The reason I had imported it was trying to set up Meilisearch on a VM following their guide here: https://docs.meilisearch.com/create/how_to/gcp.html
I ended up deleting the VM since I didn't use Meilisearch, but I guess this bucket was left behind.
I'm going to delete it since I don't even have the VM left, and can't think of a reason why I'd need that bucket. (if this turns out to be a terrible idea and everything breaks, I'll be sure to come back here and post about it)
QUESTION
I am trying to use the WebSerial API on Windows after it worked fine on macOS with no problem. The device was plugged into a Macbook and no extra action was required. When I connect the device (USB to Serial adapter) to a Windows machine and access my Angular website using Google Chrome, I get this error:
DOMException: Failed to open serial port.
When I access chrome://device-log/
I see this error:
[USB][ERROR][17:09:20] Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
Below is the code that I am using, and an error is displayed when code runs line await this.scale.open({ baudRate: 9600 });
.
ANSWER
Answered 2021-Aug-03 at 09:42It was a driver issue.
Most old models USB to Serial adapters are presenting problems on Windows 10. After trying several drivers, I found this one that solved my problem.
It is linked to a Youtube video in a language that I do not understand. However, the steps are easy to follow. After downloading the driver and following the steps, it works just fine.
QUESTION
I have been able to connect a sensor via Bluetooth to my Raspberry Pi and receive its information with the Serial Port Profile using the Python Socket library with this program:
...ANSWER
Answered 2021-Feb-02 at 15:01It looks like there is a Bluetooth Serial Port Profile (SPP) server running on the sensor and so the SPP client on the Raspberry Pi connects and exchanges information successfully.
Python sockets for Bluetooth SPP on Windows was only introduced in Python 3.9 so you will need a recent version of Python on your Windows computer.
However, if it has connected, then maybe you need to go hunting for the serial port it has connected it to. Maybe the following will help: https://www.instructables.com/Raspberry-Pi-Bluetooth-to-PuTTY-on-Windows-10/
However a more typical setup would be that the Raspberry Pi would be a bridge between the sensor and the network. This means that the value from the sensor goes to the RPi by Bluetooth. Then the RPi makes the sensor data available over WiFi/internet via a website/socket running on the RPi.
As a side note, you could be a little more efficient with your unpacking of the data. For example:
QUESTION
I am trying to update a JTextBox with data from a serial port in java swing. The problem I am facing is that the JTextBox is not getting updated. I tried repaint() and revalidate functions also but not use. I also tried putting the setText() inside a runnable. Nothing works. Please guide me in this.
...ANSWER
Answered 2021-Feb-01 at 10:34I found out the issue. I am trying to update the UI from another class by creating a new object for the UI. The actual UI was created from void main using a different object.
I resolved it by passing the existing object to the class that was calling the UI update function.
Thank you for your help people.
QUESTION
I have a problem with communication via Modbus RTU. First of all sorry for my English ;):
- I'm using RS485 Pi SN65HVD72 to connect with MultiCONT PRD-28-2. I made everything like is in this instruction: https://www.abelectronics.co.uk/kb/article/1035/raspberry-pi-3-serial-port-usage
config.txt changes:
- toverlay=pi3-miniuart-bt
- enable_uart=1
After this steps the config of my /dev looks like this:
- lrwxrwxrwx 1 root root 7 gru 30 15:03 serial0 -> ttyAMA0
- lrwxrwxrwx 1 root root 5 gru 30 15:03 serial1 -> ttyS0
- In MultiCONT PRD-28-2 I change RS485 options to:
- Protocol: Modbus
- Parity: ODD
- Stop bit: 1 bit
- Python code:
ANSWER
Answered 2020-Dec-30 at 22:54PyModbus is not receiving a response.
If you have access to an oscilloscope, this is the moment to use it. There are soooo many things that can go wrong with Modbus-RTU.
Make sure you know what you are doing with the electrical wiring, familiarize yourself with RS485 biasing and termination.
Possible causes:
- request sent to wrong serial device/interface
- device uses different baudrate or serial settings
- device can hear you allright but has a different slave ID configured, so it doesn't respond
- wrong wiring, grounding issues
- RS485 electrical problems, most notably the master must be biasing the bus, usually via a resistor that you have to solder/enable
- Bus termination resistors are required for correct voltage levels (sometimes they are already built-in, more often you need to enable them, with some luck may work without)
- Master still driving the RS485 bus while the slave is responding. (If you do not have a dedicated RS485 driver, the bus may end up being asserted/deasserted by unreliable software timers. Some devices allow you to configure a response delay as a workaround.)
- Master not driving the bus at all. (Working in RS232 mode instead of RS485 mode.)
- Also, Linux might have ttyAMA0 configured as a serial console for boot/kernel messages. (This is unlikely to cause your current problem, just something else to watch out for.)
Final piece of advice: if you have the option to use Modbus-TCP instead of Modbus-RTU, do that instead. This replaces all the RS485 electrical headaches which IP-configuration headaches, for which you can use over-the-counter medication.
QUESTION
I'm having trouble getting GPS data from my modem consistently. Normally I can get the GPS in Python with the following code:
...ANSWER
Answered 2020-Nov-22 at 13:38You should be able to utilize ModemManager to get the GPS location instead of getting it directly. This way you can avoid using the same serial port from two services.
There is documentation on how to do this from the command line using the mmcli
tool in the ModemManager manpage:
https://www.freedesktop.org/software/ModemManager/man/1.0.0/mmcli.8.html#lbBC
There is also a libmm-glib
library which you should be able to use from Python via GObject Introspection without running the command line tool.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install serial-port
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page