serial-port

C# SerialPort - Problems mixing ports with different baud rates.

Greetings, I have two devices that I would like to connect over a serial interface, but they have incompatible connections. To get around this problem, I connected them both to my PC and I'm working on a C# program that will route traffic on COM port X to COM port Y and vice versa. The program connects to two COM ports. In the data r...

Fake serial communication under Linux

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 =...

Reading Serial Data From C (OSX /dev/tty)

I am trying to read data from a bluetooth barcode scanner (KDC300) using C. Here is the code I have so far, and the program successfully establishes a bluetooth connection to the scanner, but when a barcode is scanned, no input is displayed on the screen (Eventually more will be done with the data, but we have to get it working first, ri...

Getting wrong serial-port names from bluetoothdevice (c#)

To get all avaliable Serialports from the system i use the following command. SerialPort.GetPortNames It works fine for the mainboard serial port, but with the bluetooth device i get the wrong portnames. For Example: Instead of COM7 i get sometimes COM70 or COM7ö. Its always 1 letter to much. any suggestens? PS: I am using newest ...

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

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, i.e. those usually supporting baud rates and RTS/CTS flow control? The solution would be coded in C. I ask because I am us...

Serial Port Data Structure

I need to send data to a hardware device over serial port. I'm using a program called serial port tool for os x. After I connect to the device there is a form box where I can type data to send. I have no idea how to format the data. Here is an excerpt from the manual for the device. "The Net Manager Command structure consists of one ...

Clear data at serial port in Linux in C?

I am testing the sending and receiving programs with the code as The main() function is below: #include "lib.h" int fd; int initport(int fd) { struct termios options; // Get the current options for the port... tcgetattr(fd, // Set the baud rates to 19200... cfsetispeed( cfsetospeed( // Enable the receive...

Ruby SerialPorts

I'm using the ruby serial port gem. After I open up the port I send the data I want like this. sp.write [200.chr, 30.chr, 7.chr, 5.chr, 1.chr, 2.chr, 0.chr, 245.chr].to_s It doesn't work, but if I put it in a loop of around 200 times: 200.times do sp.write [200.chr, 30.chr, 7.chr, 5.chr, 1.chr, 2.chr, 0.chr, 245.chr].to_s end It ...

How to check status of the serial terminal buffer from userspace in C

I am writing a serial communication program in userspace. I want to check how much of the buffer is full. Is there a way to do it using linux terminal i/o api? Thanks ...

LF/CR issue with RS232 in Linux

I've been having this problem where anytime I send a 0xA through an RS-232 in a Linux OS the receiver interprets that as 2 bytes, 0xD and 0xA. Also whenever I receive 0xD the serial port interprets that as 0xA. I've been reading that there are known issues regarding this, has anybody been able to find a solution? ...

Sharing a COM port over TCP

What would be a simple design pattern for sharing a COM port over TCP to multiple clients? For example, a local GPS device that could transmit co-ordinates to remote hosts in realtime. So I need a program that would open the serial port and accept multiple TCP connections like: class Program { public static void Main(string[] args...

Expected output from an RM-1501 RS232 interface?

I have an old RM-1501 digital tachometer which I'm using to try to identify the speed of an object. According to the manual I should be able to read the data over a serial link. Unfortunately, I don't appear to be able to get any sensible output from the device (never gives a valid speed). I think it might be a signalling problem becau...

Thread to receive the messages from serial port is not working using c#

I am using Serial port to receive the messages. The below function is running in a thread. When i debug i find that the thread is running properly. But "if (sp.IsOpen)" is always false, due to which the code is not executing inside the IF condition at all. It says the Port is closed. I will be having multiple serial ports in my system a...

DataReceived Event handler not receiving messages

I'm using the below code to receive the messages using serial port event handler. But it dosent receives any.I am not getting errors. The code breaks in "string msg = comport.Readline()" Am i doing something wrong ? public partial class SerialPortScanner : Form { private SerialPort comPort = new SerialPort(); public SerialPortS...

Receiving messages part by part from serial port using c#

I am using the below code to receive the messages from serial port using c# void comPort_DataReceived(object sender, SerialDataReceivedEventArgs e) { if (comPort.IsOpen == true) { string msg = comPort.ReadExisting(); MessageBox.Show(msg.Trim()); } } The problem is, i am getti...

How to Determine the serial port name connected to other machine using .NET?

I need to Determine the serial port name connected to other machine using c#. ...

How to create multiple threads in c#

I am need to listen to all the serial ports in my machine. Say if my machine has 4 serial ports, i have to create 4 threads and start listening to each port with the attached thread respectively. I used this code to get the number of ports in my machine.. private SerialPort comPort = new SerialPort(); public void GetAllPortNamesAv...

How to send a reply message to sender machine via serial port using c#

I am using the below code to receive the message via serial port which is working fine. Now i need to send back a acknowledgment message to the sender machine. How can send the message ? private void MonitorSP_DataReceived(object sender, SerialDataReceivedEventArgs e) { try { System.IO.Ports.Serial...

How to find the serial ports that are getting response after sending MSG using c# ??

The objectve is to find which Serial port is phyisically connected to other machine. I want to Search my system to find the available serial ports and send a test message using all the ports and wait for the response. And get the port numbers of Which ever ports get a response is connected to the other machine. How to do?? Thanks. ...

How can I listen to multiple Serial Ports asynchronously in C#

I have an application that listens to a piece of hardware on a USB to Serial converter. My application should monitor more than one serial port at the same time. I loop the serial ports I need to listen to, and create a thread for each port. In the thread I have my data handing routine. When I assign one port, it runs flawlessly. When ...