serial-port

How to set baud rate to 307200 on Linux?

对着背影说爱祢 提交于 2019-12-17 06:10:09
问题 Basically I'm using the following code to set the baud rate of a serial port: struct termios options; tcgetattr(fd, &options); cfsetispeed(&options, B115200); cfsetospeed(&options, B115200); tcsetattr(fd, TCSANOW, &options); This works very well. But know I have to communicate with a device that uses a baud rate of 307200. How can I set that? cfsetispeed(&options, B307200); doesn't work, there is no B307200 defined. I tried it using a MOXA Uport 1150 (that's actually a USB-to-serial converter

How to find all serial devices (ttyS, ttyUSB, ..) on Linux without opening them?

左心房为你撑大大i 提交于 2019-12-17 03:46:35
问题 What is the proper way to get a list of all available serial ports/devices on a Linux system? In other words, when I iterate over all devices in /dev/ , how do I tell which ones are serial ports in the classic way, that is, those usually supporting baud rates and RTS/CTS flow control? The solution would be coded in C. I ask because I am using a third-party library that does this clearly wrong: It appears to only iterate over /dev/ttyS* . The problem is that there are, for instance, serial

Reading and writing to serial port in C on Linux

▼魔方 西西 提交于 2019-12-17 03:46:26
问题 I'm trying to send/receive data over an USB Port using FTDI , so I need to handle serial communication using C/C++. I'm working on Linux (Ubuntu). Basically, I am connected to a device which is listening for incoming commands. I need to send those commands and read device's response. Both commands and response are ASCII characters . Everything works fine using GtkTerm but, when I switch to C programming, I encounter problems. Here's my code: #include <stdio.h> // standard input / output

How to find all serial devices (ttyS, ttyUSB, ..) on Linux without opening them?

删除回忆录丶 提交于 2019-12-17 03:46:15
问题 What is the proper way to get a list of all available serial ports/devices on a Linux system? In other words, when I iterate over all devices in /dev/ , how do I tell which ones are serial ports in the classic way, that is, those usually supporting baud rates and RTS/CTS flow control? The solution would be coded in C. I ask because I am using a third-party library that does this clearly wrong: It appears to only iterate over /dev/ttyS* . The problem is that there are, for instance, serial

SerialPort not receiving any data

拈花ヽ惹草 提交于 2019-12-16 19:54:31
问题 I am developing program which need to interact with COM ports. By learning from this Q&A: .NET SerialPort DataReceived event not firing, I make my code like that. namespace ConsoleApplication1 { class Program { static SerialPort ComPort; public static void OnSerialDataReceived(object sender, SerialDataReceivedEventArgs args) { string data = ComPort.ReadExisting(); Console.Write(data.Replace("\r", "\n")); } static void Main(string[] args) { string port = "COM4"; int baud = 9600; if (args

ObjectDisposedExecption after closing a .NET SerialPort

我们两清 提交于 2019-12-14 03:40:06
问题 I am using a .NET 4 SerialPort object to talk to a device attached to COM1. When I am done with the device, I call Close on the SerialPort. I do not call Dispose, but I believe that Close and Dispose are synonymous here. Usually this works just fine. Sometimes, however, I get the following exception some time later (The times I've seen range from 5 ms to 175 ms): System.ObjectDisposedException: Safe handle has been closed at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean&

Not receiving reply from syringe pump via rs232 using MSComm1.Input

♀尐吖头ヾ 提交于 2019-12-14 03:33:49
问题 I am trying to communicate with the syringe pump from PC through rs232. I want to send a string "02DC;50803" to the pump for establishing the communication and pump should reply "C" . I am using MSComm1.Output="02DC;50803" to send the command and Text1.Text=Text1.Text+MSComm1.Input for receiving. When MSComm1.Output executes I am able to see a LED blinking on the end device but there is no reply using MSComm1.input . Please help me out with this problem and if I put these instruction under

Stange Behavior of the Serial Port Input Buffer

二次信任 提交于 2019-12-14 03:14:10
问题 Using a virtual serial port w/usbser.sys as driver; I get some strange behavior of the buffers. I use Win32 calls (CreateFile, ReadFile, etc) rather than the SerialPort class in .NET for performance reasons. After opening the COM port, I use SetupComm(hFile, dwInQueue, dwOutQueue) to set the input buffer to 32768. I've tried with other sizes, eg. 4096, 8192, etc. Then I read the buffer size back with GetCommProperties(hFile, lpCommProp) and read the COMMPROP.dwCurrentRxQueue to check if the

Timeout exception when writing to a virtual COM

巧了我就是萌 提交于 2019-12-14 03:12:34
问题 I am trying to write to COM port using .net sample I have no problem to write to a real COM, but when I try to write to a virtual COM I get a timeout exception Unhandled Exception: System.TimeoutException: The write timed out. at System.IO.Ports.SerialStream.Write(Byte[] array, Int32 offset, Int32 count , Int32 timeout) at System.IO.Ports.SerialPort.Write(String text) at System.IO.Ports.SerialPort.WriteLine(String text) I googled the issue, and found this. according to what is said there this

Clear Pole Display text using chrome serial

痞子三分冷 提交于 2019-12-14 03:11:53
问题 I have created a chrome application to connect to a Pole Display through serial port, I have succeeded with writing to it, but every time I send a message, it concatenates it with the previous one, I can't find a way to clear the screen each time I send a new message ! Here's my code: var connectionId = -1; openPort("COM3"); function openPort(port){ var onOpen = function(connectionInfo) { if (!connectionInfo || connectionInfo.connectionId == -1) { return; } connectionId = connectionInfo