serial-port

Serial port does not work in rewritten Python code

ぐ巨炮叔叔 提交于 2019-12-23 15:36:46
问题 I have a Python program that reads some parameters from an Arduino and stores it in a database. The serial port is set up and used like this: ser = serial.Serial(port=port, baudrate=9600) ser.write('*') while 1 : ser.write('*') out = '' # Let's wait one second before reading output (let's give device time to answer). time.sleep(1) while ser.inWaiting() > 0: out += ser.read(1) if out != '': etc ... handling data (The Arduino is set up so when it receives a star, it sends back a data string.) I

How to wait for input from the serial port in the middle of a program

空扰寡人 提交于 2019-12-23 12:58:01
问题 I am writing a program to control an Iridium modem that communicates with a satellite. After each AT command is sent, the modem sends a reply back (depending on the command) to indicate the command was successful. Right now I have it implemented so that the program just waits 10 seconds between the transmission of each command to the modem, but this is a bit risky because it does not allow for error handling in case the command is not successfully interpreted. The only way I know how to read

Opening a virtual serial port created by SOCAT with Qt

浪尽此生 提交于 2019-12-23 09:29:12
问题 I'm developping a Qt5 application on MacOS. I would like to test my application serial port communication. I'd like to use socat but I'm unable to open the port created with socat: QSerialPortInfo::availablePorts() lists only the /dev/cu-XXXXXX ports... 回答1: Socat port creation example: socat pty,link=/dev/mytty,raw tcp:192.168.254.254:2001& After this you get your pseudo port /dev/mytty Now you can reference this port via QSerialPort serial = new QSerialPort("/dev/mytty"); 回答2: You might be

Windows Universal App Serial Ports won't open, SerialDevice.FromIdAsync always null

六月ゝ 毕业季﹏ 提交于 2019-12-23 08:49:44
问题 I am trying to use serial ports in a Windows Universal Application. I have been using Microsoft's Serial Sample application as a template however I have hit a rather strange issue. var dis = await DeviceInformation.FindAllAsync(SerialDevice.GetDeviceSelectorFromUsbVidPid(0x04D8, 0x000A)); var sp = await SerialDevice.FromIdAsync(dis[0].Id); This is a the snippet that is failing. It is slightly altered from the original sample as it connects to the first device with a specific vendor. Now if I

Unblock synchronous read on boost::asio::serial_port

自闭症网瘾萝莉.ら 提交于 2019-12-23 08:47:08
问题 I have a boost::thread which performs synchronous reads on a boost::asio::serial_port . When I destroy an instance of the class which contains both, I want the thread to end gracefully even if its blocked in a read call. How can I do this? Looking at the docs, I tried cancel , but it works only for asynchronous reads/writes. Then I tried close , but I got an exception and it wasn't the kind you can recover from. Perhaps using send_break or native_handle ? (this is Windows and portability's

CreateFile() returns INVALID_HANDLE_VALUE but GetLastError() is ERROR_SUCCESS

跟風遠走 提交于 2019-12-23 08:30:10
问题 I am opening a serial port using CreateFile(). I've got a testcase (too complicated to redistribute) that consistently causes CreateFile() to return INVALID_HANDLE_VALUE and GetLastError() to return ERROR_SUCCESS . By the looks of it, this bug only occurs if one thread opens the port at the exact same time that another port closes it. The thread opening the port runs across this problem. I don't know if this makes a difference, but later on in the code I associate the port with a

CreateFile() returns INVALID_HANDLE_VALUE but GetLastError() is ERROR_SUCCESS

血红的双手。 提交于 2019-12-23 08:30:02
问题 I am opening a serial port using CreateFile(). I've got a testcase (too complicated to redistribute) that consistently causes CreateFile() to return INVALID_HANDLE_VALUE and GetLastError() to return ERROR_SUCCESS . By the looks of it, this bug only occurs if one thread opens the port at the exact same time that another port closes it. The thread opening the port runs across this problem. I don't know if this makes a difference, but later on in the code I associate the port with a

Is it possible to use 9-bit serial communication in Linux?

半世苍凉 提交于 2019-12-23 07:07:29
问题 RS-232 communication sometimes uses 9-bit bytes. This can be used to communicate with multiple microcontrollers on a bus where 8 bits are data and the extra bit indicates an address byte (rather than data). Inactive controllers only generate an interrupt for address bytes. Can a Linux program send and receive 9-bit bytes over a serial device? How? 回答1: The termios system does not directly support 9 bit operation but it can be emulated on some systems by playing tricks with the CMSPAR flag. It

Boost Asio serial port issue

China☆狼群 提交于 2019-12-23 05:01:59
问题 I'm using CodeBlocks on a windows systems and have downloaded Boost, complied and setup my IDE variables and build options. I have been successfully using other boost libraries and now I need to work on a program that reads and writes to a serial port. I can not get any example that I try to compile for asio serial port. The following, for example will generate a compile error which follows the code: #include <iostream> #include <boost/asio.hpp> #include <boost/asio/serial_port.hpp> #include

c# serial port listener [closed]

做~自己de王妃 提交于 2019-12-23 04:47:44
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . Is in C# any serial port listener, that will call my function if there will be any data on serial port? My only idea is to use infinite loop, something like this: while true if someDataOnSerialPort callmyfunction(serialPortData) ? Any handler that will call my function if there