serial-port

How do I ensure that a Python while-loop takes a particular amount of time to run?

♀尐吖头ヾ 提交于 2019-12-30 03:28:03
问题 I'm reading serial data with a while loop. However, I have no control over the sample rate. The code itself seems to take 0.2s to run, so I know I won't be able to go any faster than that. But I would like to be able to control precisely how much slower I sample. I feel like I could do it using 'sleep', but the problem is that there is potential that at different points the loop itself will take longer to read(depending on precisely what is being transmitted over serial data), so the code

Fake serial communication under Linux

别说谁变了你拦得住时间么 提交于 2019-12-30 00:58:28
问题 I have an application where I want to simulate the connection between a device and a "modem". The device will be connected to a serial port and will talk to the software modem through that. For testing purposes I want to be able to use a mock software device to test send and receive data. Example Python code device = Device() modem = Modem() device.connect(modem) device.write("Hello") modem_reply = device.read() Now, in my final app I will just pass /dev/ttyS1 or COM1 or whatever for the

Send data to a barcode scanner over RS232 serial port

对着背影说爱祢 提交于 2019-12-29 09:00:30
问题 I have a bar-code scanner which is connecting through RS232 serial port. I need to write a program to connect this device with the PC and transmit data. I already wrote some basic methods to initialize a communication link and tried to test by sending a BEEP command to the device but it is not beeping as expected. So I think there is something wrong with my source code. Please somebody help me complete the source code. Below is the written source code 01)DeviceRS232.h #ifndef DEVICERS232_H

CommPortIdentifier.getPortIdentifiers is empty

别说谁变了你拦得住时间么 提交于 2019-12-29 08:43:12
问题 I am building a simple application that communicates through Serial Port using the Java Communication API javax.comm. Here is some code in my java main method I wrote: CommPortIdentifier cpi = null; Enumeration e = CommPortIdentifier.getPortIdentifiers(); while (e.hasMoreElements()) { try { cpi = (CommPortIdentifier) e.nextElement(); } catch (NoSuchElementException n) { } System.out.println(cpi.getName()); } Enumeration e is always empty even though I am connected to a COM 4 port when running

How to access my 9-data bit serial port on a PC?

穿精又带淫゛_ 提交于 2019-12-29 07:58:09
问题 I have developed an embedded solution which communicates over a Multi Drop Bus and now I would like to develop a PC based application which monitors traffic on the bus. MDB supports true 9 data bits (plus start/stop/parity - and *no fudging* by using the parity bit as a 9th data bit) whereas standard Windows and Linux libraries offer a maximum of 8 data bits. I have a StarTech PCI2S950 PC serial port card which supports 9-data bits, but am not sure how to code my monitoring app & have googled

What is proper way to detect all available serial ports on Windows?

佐手、 提交于 2019-12-29 04:28:28
问题 There are several ways to list serial ports under Windows but I'm not sure what is the proper way: the way that does detect all serial ports that are available. One good code example is http://www.naughter.com/enumser.html - where there are 9 (nine!) ways of enumerating serial devices. The question is: what is the optimal way of doing it. Requirements: to not open ports in order to check if they are available. to be able to detect ports with different names than COMx . to work on Windows XP

Low latency serial communication on Linux

早过忘川 提交于 2019-12-29 03:15:08
问题 I'm implementing a protocol over serial ports on Linux. The protocol is based on a request answer scheme so the throughput is limited by the time it takes to send a packet to a device and get an answer. The devices are mostly arm based and run Linux >= 3.0. I'm having troubles reducing the round trip time below 10ms (115200 baud, 8 data bit, no parity, 7 byte per message). What IO interfaces will give me the lowest latency: select, poll, epoll or polling by hand with ioctl? Does blocking or

C# await event and timeout in serial port communication

天大地大妈咪最大 提交于 2019-12-29 02:09:28
问题 Hi I have a simple communication on serial port well all is according to book and documentation so open port method looks like this: public SerialPort OpenPort(string portName) { Port = new SerialPort(portName, BaudRate); try { Port.Open(); Port.DtrEnable = true; Port.RtsEnable = true; Port.DataReceived += DataReceivedEvent; } catch (Exception e) { Console.WriteLine($"ERRROR: {e.Message}"); } return Port; } Here we have an event on data read: private async void DataReceivedEvent(object sender

How to programmatically find all available Baudrates in C# (serialPort class)

删除回忆录丶 提交于 2019-12-28 16:46:58
问题 Is there a way to find out all the available baud rates that a particular system supports via C#? This is available through Device Manager-->Ports but I want to list these programmatically. 回答1: I have found a couple of ways to do this. The following two documents were a starting point http://support.microsoft.com/default.aspx/kb/99026 http://msdn.microsoft.com/en-us/library/aa363189(VS.85).aspx The clue is in the following paragraph from the first document The simplest way to determine what

Getting device/driver information related to a COM port?

£可爱£侵袭症+ 提交于 2019-12-28 13:51:14
问题 I have a Serial-to-USB device with a similarly named device driver in the Windows device manager. The devices do not always grab the same COM port on system boot, so my program needs to identify it on start up. I've tried using RXTX to enumerate the COM ports on the system, but this didn't work because CommPortIdentifier.getName() simply returns the COM name (eg. COM1, COM2, etc.) I need to acquire either the driver manufacturer name, or the driver name as it appears in the device manager,