Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [serial-port]

A serial port is a physical interface through which data is transferred (uni- or bidirectionally) one bit at a time. Largely superseded in the consumer market by USB, serial connections are still commonly used in many other specialist applications. Typical applications include scientific/medical instruments, industrial controllers and server diagnostics...

Filter by
Sorted by
Tagged with
15 votes
2 answers
6k views

Asynchronous serial port communications class in C++

Please review my serial port class written in C++. It is completely asynchronous, ie event driven. My idea for later is to inherit from this a sync_serial, where timeouts can be specified and it ...
arcomber's user avatar
  • 2,449
11 votes
5 answers
71k views

Reading from a serial port

I'm receiving data from a serial port in C, using Serial Programming Guide for POSIX Operating Systems as a guide. The data I receive should be always 10 bytes in length but I want to be sure that, ...
user2018761's user avatar
11 votes
1 answer
2k views

Door-opener program

I've been working on a little project on an Arduino and I need some help with making the code more efficient / cleaner. I really don't like the three for loops and ...
Bavilo's user avatar
  • 211
10 votes
4 answers
63k views

SerialPort class for a library

I've been working a lot recently with SerialPort in C# and I've come up with the following class as part of a class library I'm working on for another program. My question is, are there any more ...
DanteTheEgregore's user avatar
9 votes
2 answers
1k views

Serial port library across different compilers

I'm writing a C++ library with MinGW (4.8.0, DW2, POSIX) compiler. But this library must be used by another compiler. I've read this post, so I've re-written the C++ library interface in this way: <...
Elvis Dukaj's user avatar
8 votes
1 answer
7k views

Verilog UART Transmitter

This is one of the first Verilog programs I have written. I have a Xilinx Artix-7 FPGA card. Right now I just have it transmitting an "X" every second. It works and I can see the result in my serial ...
chasep255's user avatar
  • 225
8 votes
1 answer
2k views

Wrapping libusb library in C++

I want to use libusb library in my C++ application. I have created classes which wraps libusb functions. You can see that libusb API is split into 8 sections: http://libusb.sourceforge.net/api-1.0/...
shjeff's user avatar
  • 185
7 votes
2 answers
4k views

SerialPort C# Class

Originally I submitted a question here: SerialPort class for a library I cleaned up my code a bit and rewrote a few things. I've had a number of problems along the way and I've still not gotten to ...
DanteTheEgregore's user avatar
6 votes
2 answers
8k views

Handling serial port with select and local socket

I have another issue: I'm trying to handle connections made by local socket along with data from serial port. Here is my concept: Serial port is opened and monitored by select Local socket is opened ...
user2018761's user avatar
6 votes
1 answer
11k views

Async SerialPort Wrapper

I've been working with the SerialPort class for a while, trying to figure out the best way to work with it, and especially adding support for Async-Await in C#. I ...
Benjamin's user avatar
  • 209
5 votes
2 answers
8k views

Read binary serial data and parse integers

I'm reading serial data in binary format from a stream, and I'm not happy with how I extract the data because it takes so much operations to extract the binary data from a simple line of binary data. ...
Hedge's user avatar
  • 171
5 votes
1 answer
2k views

Dynamic length binary data parsing

I am currently writing code for a UART communication in my firmware. I am getting an interrupt every byte received (meaning I don't get a chunk of data, 1 byte at a time but, in the sample below I ...
Tim's user avatar
  • 337
5 votes
2 answers
5k views

Open a comm port and send an ASCII string

This is my first ever project and first GUI. I have finished it (with help from Stack Overflow) and it works but is very slow. Can anyone suggest improvements for speed, best practices or usability.? ...
Display Name's user avatar
5 votes
1 answer
2k views

Serial port for Node.js

I am trying to create a class for serial port using Node.js, but I want to know if there is a better way to write my data class code. In my sample code below, in the ...
Tim's user avatar
  • 337
5 votes
2 answers
12k views

Find a serial port device through WMI (windows management instrumentation)

The idea here is to be able to find a USB serial port device connected during runtime, thus not knowing its port number, and use it in the application to retrieve information from the device. ...
Oscar Guillamon's user avatar
5 votes
1 answer
4k views

Programming Principles - Reading/writing from/to a Mifare card

Consider the following class (I've stripped XML doc for the sake of simplicity), which does several and slightly different operations through a serial port to read/write from/to a Mifare card. It has ...
natenho's user avatar
  • 215
5 votes
1 answer
748 views

Robot arm manipulation library

I have created a DLL library that controls an robotic arm. Could you tell me if my design is correct? The robot communicates over serial port. The code works but I would like to receive a feedback ...
Michal's user avatar
  • 51
5 votes
1 answer
172 views

Writing a class to hold Arduino Properties for an Arduino I2C Debugger

I have this class which mostly holds a bunch of properties and their setters. I also have wrappers for some functions of another module. Here is the class: ...
sawyermclane's user avatar
4 votes
3 answers
164 views

Function to check if received message matches any of the expected messages

I have a message coming in and I need to match it against the expected messages. The program will eventually do something as a result of receiving those messages. I am not very experienced at ...
Tryb Ghost's user avatar
4 votes
2 answers
10k views

Serial Port Communication

This is an efficiency question to the following code, written in MS Visual in C#. If any explanation is missing, please let me know and I will add. What this part of the program does is: Button is ...
Chris's user avatar
  • 75
4 votes
2 answers
725 views

ROS node to control Dynamixel servo motors

This code is for a ROS (http://www.ros.org/) node that controls a pair of servo motors (referred to in the code as grippers) that can be controlled individually or together. When they are controlled ...
Ben H's user avatar
  • 181
4 votes
2 answers
365 views

Simple meter simulator

I've created a simple python meter simulator which connects to a serial port (in my case COM1) listens on the serial port and takes actions based on what it ...
Grajdeanu Alex's user avatar
4 votes
1 answer
348 views

8051 RFID reader for Atmel microcontroller

I am currently using an AT89S52 microcontroller for a major project that involves a use of an RFID reader that outputs data in a serial format (9600 baud, no parity, 8 data bits, 1 stop bit). The ...
Mike -- No longer here's user avatar
4 votes
1 answer
4k views

A library that reads incoming scale data from USB

I made a simple C# library which detects incoming data from 1 or 2 scales plugged into a computer's usb. My main concerns: I feel like I should potentially be using events/delegates to process the ...
Bassie's user avatar
  • 559
4 votes
1 answer
773 views

4x4 Matrix Keypad on Arduino UNO

I recently bought a 4x4 keypad. It is one like this: http://www.learningaboutelectronics.com/images/4x4-matrix-keypad-pinout.png Now every code I found on the net was either using a highly overloaded ...
clockw0rk's user avatar
  • 171
4 votes
1 answer
2k views

Controlling motors using USB serial connection from Raspberry Pi to Arduino

I am working on building an RC car/robot with Raspberry Pi and Arduino. I connected Arduino to Raspberry Pi using USB and send serial commands with python. I haven't done much programming with ...
Yan's user avatar
  • 683
4 votes
2 answers
2k views

Handle data sent back over serial by Arduino

I have a machine that is being controlled by an Arduino. If I send the machine the command '9' it will send back JSON with some sensor temperatures in the format ...
Klatch Baldar's user avatar
4 votes
1 answer
403 views

Responding to serial input

This code for the Raspberry Pi board waits for serial input then plays an arrow with a sound and message. I'd like any constructive comments or suggestions. ...
peterretief's user avatar
3 votes
1 answer
2k views

Python lookup table

I'm trying to design a protocol for sending/receiving serial data. The basic plan is to allow for text data to be entered in the command prompt, translate that to a hex string and send it out over ...
user3817250's user avatar
3 votes
1 answer
154 views

Servo commands based on serial port input

Straight to the point: Can you give me pointers on how to make this code more maintainable? In the future, I want to add more more things to this, but first it should be easy to maintain/read. Should ...
user2587674's user avatar
3 votes
1 answer
108 views

Two bidirectional Software UARTs with AT89S52 microcontroller

I have learned one way to read from a serial port via software UART is via timer interrupts. I have made an implementation of receiving data from one serial port below. I haven't tested it yet because ...
Mike -- No longer here's user avatar
3 votes
2 answers
1k views

Serial port communication app

This code connects to COM 3 which has a broadband card and sends a command that returns the RSSI value. I use this program to see patterns in signal strength in certain areas. ...
dave776's user avatar
  • 31
3 votes
0 answers
130 views

ASHv2 implementation from scratch - host, transmitter and listener

I am currently implementing the EZSP and the underlying ASHv2 protocols in Rust with the intention to use them on an embedded smart home gateway to control ZigBee devices. In this review I present you ...
Richard Neumann's user avatar
3 votes
0 answers
2k views

Structure of a serial port reading program

I am writing a serial port communication app. And I thought I could get some feedback about the general structure of the program. If I am doing MVC correct, etc. Since this is a "large" program I ...
user276581's user avatar
3 votes
0 answers
953 views

RC Plane Radio using the Raspberry Pi

This python code is for a homemade RC plane radio using the Raspberry Pi and a USB joystick. It sends values over serial to DSM2/X module for RC planes and other RC vehicles. This Python code is ...
ethan Johnston's user avatar
3 votes
0 answers
212 views

Atmega328 watchdog, sleep and external interrupts

I have a customised Arduino board that will be connected to a battery and never power reset (it needs to be very reliable and cope with code hangs). The board will always be put to sleep when not in ...
user103034's user avatar
2 votes
2 answers
2k views

Serial-data read buffer handling

This is a follow-up to yesterday's codereview-question about reading serial data and parsing it. The code below is run into a seperate thread looped endlessly. Currently I track the position in my <...
Hedge's user avatar
  • 171
2 votes
2 answers
3k views

Reading range sensor data from one Serial Port and writing output to another

I'm reading range/distance sensor data from one Serial Port, decoding it and then transmitting it to a secondary device in ASCII format. The sensor uses a 2-byte header with each byte containing the ...
Thabiso Mofokeng's user avatar
2 votes
1 answer
155 views

Feedback on Traffic Light which revolves around Serial Communication

Assignment description I'd like to receive feedback on an assignment which I'm currently working on. I have to make two traffic lights which allow traffic to run smoothly. I'm using a master Arduino ...
Stefan2000's user avatar
2 votes
1 answer
141 views

Handling command code and response code in serial port's DataReceived method

I have a function which contains two switches, which check for Command Code and Response Code after that updating UI elements. The code is working fine. How I can reduce or improve those switch cases?...
Prashant Pimpale's user avatar
2 votes
2 answers
7k views

C# SerialPort implementation

I'm writing a C# WPF project built with a MVVM pattern. This software is written to use a medical diagnostic device, so in our planning it will be certified IEC 62304. Since I've been mainly writing ...
Lori's user avatar
  • 121
2 votes
1 answer
474 views

RPi script to periodically collect data from Arduino through serial port

I'm not used to Python. The script opens serial communications with an Arduino unit and send commands to and receives information from the Arduino. It is intended to run indefinitely until the system ...
Nogurenn's user avatar
  • 123
2 votes
1 answer
259 views

Arduino serial data input output

I have created an Arduino sketch that I am using to send and receive data via serial. It works pretty well and doesn't seem go wrong as long as the correct formats are received. Is there anything I ...
Oisian's user avatar
  • 29
2 votes
1 answer
269 views

Arduino Create and send data to Serial Port (Software Serial function)

I have this code written and functioning that will write out the chars in cmd to a serial port for an input of two int values. As the majority of the byte values ...
ATE-ENGE's user avatar
  • 123
2 votes
2 answers
2k views

Serial port write buffer

I'm writing to some serial comm port with specific bytes set into buffer. My protocol for write buffer is written below. Platform is Windows and IDE is Visual C++. Byte 0 will have message type ...
hypheni's user avatar
  • 191
2 votes
0 answers
7k views

What is better - using SerialPort with or without await/async methods?

I'm having an implementation using SerialPort in C# using Visual Studio 2019. I'm using it in a Windows Application, using .NET Framework 4.7.2. When I open and ...
Hans Billiet's user avatar
2 votes
0 answers
91 views

Await data coming from an event [closed]

This is a USB related question, but the problem is not USB specific. When reading data from a USB endpoint, there are two patterns I am concerned with. Request/Response like HTTP (done over the Bulk ...
Christian Findlay's user avatar
2 votes
0 answers
186 views

Blocking serial port C library

I am planning to write a reasonably feature rich serial library but wanted to cut my teeth on something fairly basic. This serial library is fairly simple. It is a thin wrapper on the UNIX open, ...
arcomber's user avatar
  • 2,449
2 votes
0 answers
3k views

Serial Port Wrapper with Internal Blocking Buffer

Here I have some complete working code but some aspects seem questionable to me. What I have done is written a wrapper for the Microsoft serial port (...
Snoop's user avatar
  • 121
2 votes
0 answers
267 views

Fetching a weather report on an Arduino from a web service

I'm writing some code which is basically supposed to http get some information from my own website and parse it, which (finally) works. However, when I compile the code, it shows this: Sketch uses ...
Kyranstar's user avatar
  • 1,191