Click here to Skip to main content
15,894,312 members
Everything / Serial

Serial

serial

Great Reads

by Bernhard Nebel
How does asynchronous serial communication work, what Arduino libraries are there to support it, and what can go wrong?
by debashishPaul
How to Get 'serial' value of the Inserted Record and Use with a Variable in PostgreSQL
by ToughDev
In my previous article I provided some information on the Tektronix TDS 340 100 MHz digital storage oscilloscope and instructions
by Vedat Ozan Oner
Arduino.SerialLcd library

Latest Articles

by ToughDev
Emulate parallel port printer to capture data from Tektronix 1230 Logic Analyzer
by ToughDev
How to interface Nokia 3510i and 5110 LCD with PIC Microcontroller
by Minh Danh Nguyen (ToughDev)
Developing vintage 68K Macintosh apps with CodeLite IDE, Retro68 and pce-macplus emulator
by ToughDev
Interesting findings about GSM SIEMENS TC35

All Articles

Sort by Score

Serial 

21 Jan 2022 by Bernhard Nebel
How does asynchronous serial communication work, what Arduino libraries are there to support it, and what can go wrong?
18 Feb 2016 by debashishPaul
How to Get 'serial' value of the Inserted Record and Use with a Variable in PostgreSQL
2 Jan 2012 by Kim Togo
Use SerialPort Class[^]. From there you can do anything :-)And you are lucky. Check this out:Serial Port Programming Part 1 – A (very) brief introduction[^]Serial Port Programming Part 2 – Developing a GUI to set the Port Settings and validating the data[^]Serial Port Programming –...
2 Jan 2012 by Un_NaMeD
That's pretty simple in .Net. You need to add these library:using System.IO.Ports;To open/close a port:serialport.Open();serialport.Close();but you need to be carefull not the open an open one. You need to check if it's open or not with:serialport.IsOpen();Then you can...
26 May 2012 by SoMad
I have done a lot of work with RS232 input in my time and I have encountered several pitfalls that I did not expect to stumble across.You are not specifying if you are using a "real" COM port or a USB COM port device. The USB COM port devices are great, but they do not work 100% as a native...
26 Oct 2012 by CPallini
If you are programming for Windows, I suggest you to use directly Windows API. They are very well documented documented[^] and relatively simple.
24 Feb 2013 by Richard MacCutchan
Some useful links[^].
24 Feb 2013 by Thomas Daniels
Hi,Have a look here:Serial Communication using C# and Whidbey[^]Serial Port...
2 Jan 2014 by Ron Beyer
Serial ports do not provide power, the pins are, in order:1: DCD or Data Carrier Detect2: RX or Receive3: TX or Transmit4: DTR or Data Terminal Ready5: Signal Ground6: DSR or Data Set Ready7: RTS or Request To Send8: CTS or Clear To Send9: RI or Ring IndicatorNone of...
28 Mar 2015 by Sergey Alexandrovich Kryukov
Hey Sergey! Thiago wrote:I actualy didn't know this. Thanks for telling me! Someone formatted it for me. Ok, I've been told that SetPixel is too slow, but I am afraid I don't know what else to do. Do you have tips? Could you recommend a real-time plot library?Thanks,ThiagoYou are...
21 Aug 2015 by Member 11915058
OMG!I found it, in port settingDtrEnable=TrueKudos for Ed Tenholder
18 May 2016 by Patrice T
Advice:- use a char array to store the data received from serial. You can't have expectations about what is the data you are receiving. Never receive in a string and then transform to char.- To debug the serial link, replace 1 of the devices with a computer using a terminal emulator. it will...
26 Sep 2018 by Dave Kreskowiak
Your code is written to expect an entire message in one "receive packet" but that's not how communication, over ANY network, works. Your receive code has to buffer whatever is gets and keeps on adding to the buffered content on subsequent receive events until a complete message has been...
13 Sep 2021 by Patrice T
Quote: How can I send hexadecimal data to serial port in C#? Exactly the same method you use to send normal text. Hexadecimal user input is standard text, just a string.
26 Nov 2021 by Richard MacCutchan
VarString$ = "FF 01 01" That is what you are doing wrong. You are sending the ASCCI character string FF0101 instead of the actual hex (i.e. 8-bit) bytes FF0101. You need to use the VBA HEX function to get the correct values,...
7 May 2023 by ToughDev
In my previous article I provided some information on the Tektronix TDS 340 100 MHz digital storage oscilloscope and instructions
3 Aug 2023 by CPallini
The good news is the manufacture provides plenty of documentation. The bad news is you have to study it (we cannot do that for you). In my experience, the MODBUS protocol is fairly simple to understand, you could start with it.
20 May 2011 by barneyman
it looks like that product outputs the NMEA over the com port so another external device can consume it - not really what you're afterEither connect another computer with a null modem cable (or a computer to itself if it has 2 com ports) or use a virtual serial driver that understands how to...
30 May 2011 by Timberbird
1. You can duplicate thread handle and use it with WaitForSingleObject() function as described here[^]. Generally (regarding other cases, when you just need to wait for some time - your listeningThread function, for example), using Sleep() is not recommended, consider using WaitForSingleObject...
26 Jul 2011 by OriginalGriff
Probably, your problem is that you are calling DiscardInBuffer so often. If your VB code is out of sync with your Arduino code (and lets face it, it will be since the Arduino is continuously pumping data in realtime with a brief delay, and the VB is working when windows feels like it) There is a...
10 Apr 2013 by Sergey Alexandrovich Kryukov
You are pretty much right about "no", but this is not really related to serialization. You cannot change the declaration of a type during run-time. This fact is more fundamental than serialization. I don't know why would you want it (that's why you are advised to tell us your ultimate goals); I...
30 Aug 2013 by Sergey Alexandrovich Kryukov
Please see: http://msdn.microsoft.com/en-us/library/windows/hardware/hh998535.aspx[^].—SA
2 Jan 2014 by OriginalGriff
Just to add to Ron Beyer's comments about pinout on serial - it is quite likely that Hyperterminal is setting some of the output signal pins high and your device is reading those and turning itself on (it may also be actually powering itself from them, if it's draw is low enough, RS232 signals...
14 Jan 2014 by Vedat Ozan Oner
Arduino.SerialLcd library
16 Feb 2014 by OriginalGriff
No, it doesn't!There is no WriteByte method in the SerialPort class: http://msdn.microsoft.com/en-us/library/System.IO.Ports.SerialPort_methods(v=vs.110).aspx[^]There is a Write method that accepts an array of bytes, but there is no specific method to send a single byte value.What you...
4 May 2014 by OriginalGriff
Start with SerialPort.GetPortNames(v=vs.110).aspx[^] to find all available ports to the system, then you pretty much have to try to Open each one in a try...catch block and use only those that don't fail. There is no "IsFree" property for a comport and "IsOpen" only tracks ports within the...
13 Mar 2015 by bling
Take a look at this line:tx = ReadFile(hCom,&in,1,&num,NULL);tx is declared as int but ReadFile returns BOOL. Your code should check the call for success / failure.num will have the number of characters read (eg. 0 or 1). Your code should check this before attempting to print...
21 Apr 2015 by Richard MacCutchan
If no key has been pressed then GetPressedKey returns zero, so the loop continues. You should remove these two functions, as they do nothing except delay your code.
1 Sep 2015 by Patrice T
You need:- Signal documentation- a terminal emulator (probably)In documentation, you need to find:- Communication speed- Data format: number of bits, stop, parity- Commends codesWhen you have a communication up and running, you can think about programming.
28 Sep 2015 by George Jonsson
For your purpose I would discard the code you found "somewhere on the net" and take a look at this article.Serial Comms in C# for Beginners[^]As you have a USB to RS232 converter it will enumerate as one or more Virtual COM Ports (VCP).In most ways this is the same as connecting to a...
11 Nov 2015 by veena nair
the below sketch have a serial output at the end of the sketch. "(Serial.println(stringTwo);)"How to convert it to a socket output. I want to read the out using a c# program through lan network.===========Sketch============int LED= 2;int LED3= 3;int LED4= 4;int LED5=...
16 Nov 2015 by Kornfeld Eliyahu Peter
Here my code...void rfid_msg(byte opcode, byte* data, int len){ byte* msg = new byte[len + 5]; byte response[256]; msg[0] = 0xff; msg[1] = len; msg[2] = opcode; if (len > 0) { memcpy(&msg[3], data, len); } unsigned int tmp = crc(&msg[1],...
16 Nov 2015 by User 59241
Hard coded constants are dangerous.https://www.arduino.cc/en/Reference/Int[^]0xff + opcode + len + crc == 6 bytesvoid rfid_msg(byte opcode, byte* data, int len){ byte* msg = new byte[len + 6]; byte response[256]; msg[0] = 0xff; msg[1] = len >> 8; msg[2] =...
16 Nov 2015 by Patrice T
In order to make sure of what the code is doing, I would fire the debugger on the code.I think this code is a good example of when it become useful to run the...
17 May 2016 by George Jonsson
There are quite a few different reasons why you might receive the wrong character.You are telling very little about your hardware setup, so I can only give general advice for how you can find the error.The most common is that you haven't configured the port correctly.Make dead sure you...
31 Jan 2017 by OriginalGriff
Once you open a SerialPort, it is locked and you can't open a second instance on the same hardware - only one "thing" at a time can control the port. So create it in the "outermost" of your forms, and pass the instance of the SerialPort (or its encapsulating class if you follow PIEBALDconsult's...
28 Sep 2017 by Jochen Arndt
Quote: - serial port number changes sometimes That might happen when plugging the USB-to-Serial converter into a different connector. But it should not happen when not unplugging the converter. Quote: - another application can "steal" the port and kill the communication COM ports are...
3 Feb 2019 by RickZeeland
You can use string.Split() string data = "FF A1 00 00 00 00 00 00 00 00"; string[] words = data.Split(' '); if (words[2].Equals("00")) { panel1.BackColor = Color.Green; } else { panel1.BackColor = Color.Red; } if (words[3].Equals("00")) { panel2.BackColor = Color.Green; } else { ...
12 Nov 2019 by CPallini
Your code looks correct to me. I would try to send the same string with a serial terminal (like, for instance, putty[^]) in order to check if the oven actually communicates. Then I would check the communication parameters (serial speed and flags) of the SerialPort object.
8 Feb 2021 by Richard MacCutchan
See threading — Thread-based parallelism — Python 3.7.9 documentation[^].
11 Feb 2021 by markkuk
Quote: Does python even run an event loop that the humble programmer can use and I am too blind to find it? No, unless you add such a loop by yourself or use a library/framework that sets up an event loop for you. By itself, Python is a...
8 May 2023 by ToughDev
Emulate parallel port printer to capture data from Tektronix 1230 Logic Analyzer
31 May 2011 by tschoni
NOTE: This is a reply to Timerbirds comment, posted as 'answer' simply to make code easier to readThat's the message about the memory leak. I never dealt with handle leaks before, so I'm not sure if, if it says 'memory leak', it can still be a handle leak. Can it?Detected memory...
7 Jun 2011 by Member 7986338
How do I send at+cmgd=1,4 to a gsm modem connected to comm 6 via C++?
7 Jun 2011 by Kim Togo
You have to open the comport/serial port and set baud rate etc.When you have opened the port. You can then write AT commands.
7 Jun 2011 by Stephen Wiria
Use this: Win32 SDK Serial Comm Made Easy[^]Now you see it's very easy to delete SMS :)
7 Jun 2011 by Member 7986338
I am new to using c++, could you help me with the code to do this?
4 Jul 2011 by Trevor Johansen
I am having a terrible time getting this code to work. I either get an exception at main or a jd2xx not in java.class.pathI am relatively new to java and am using NetBeans as my IDE. I would really appreciate it if someone could take a peek at the code and tell me how to get in running in...
4 Jul 2011 by TorstenH.
Check if the jd2xx.jar (what ever that is!?) is included in the build process. If it's a native Java project you should check the project properties.
8 Jul 2011 by Trevor Johansen
OK, so strangely enough I solved my problems through another issue I was having. One of my well know Java apps that ran fine before stopped responding and It was due to the fact that the /usr/bin/java shortcut had been updated to a different version of the VM.sudo update-alternatives...
19 Jul 2011 by Omparkash
End If Dim Str As String = Nothing Dim StrArray() As String = Nothing With objPort If CurrentDataMode = DataMode.Text Then Str = .comPort.ReadLine() StrArray = Split(Str, ":") For i As...
26 Jul 2011 by kile22
I'm trying to make a fairly simple program that takes temperature data from an Arduino Uno and sends it to VB 2010 to make a real time graph. So far I have the Arduino output temperatures on a new line, I know this works from the Arduino IDE serial monitor.Basically I can get input but is...
16 Sep 2011 by amsga
Hi all,I created a serial port program that reads a file and sends it across a serial link to another computer.The file contains about 2MB worth of text data in a txt file.On my other computer, contains a receiver program that writes what was read through the serial port into a txt...
31 Oct 2011 by eldonnadie
I am trying to use java comm api for serial port communication, the IDE i am using is netbeans , but somehow i can't make it work and i keep getting this mistake:Caught java.lang.UnsatisfiedLinkError: no Serial in java.library.path while loading driver gnu.io.RXTXCommDriverCan anyone...
31 Oct 2011 by CodingLover
Related with the drivers seems.http://download.oracle.com/javase/1.4.2/docs/api/java/lang/UnsatisfiedLinkError.html[^]As far as I know RXTX is crashing when the USB port was unplugged. Did you do something like that?If so try with the Windows Java Serial Com Port Driver, specifically...
23 Nov 2011 by Richard MacCutchan
Judging by this[^], I would say not.
24 Nov 2011 by Satheesh1546
Hi,This link will help youhttp://www.tech-forums.net/pc/f11/flush-serial-port-read-buffer-c-226473/[^]
29 Nov 2011 by amsga
Is there a difference in CPU usage between Asynchronous and Synchronous reads from a communication port?I've tried putting the reads in a separate thread but I don't see any difference.
29 Nov 2011 by Sergey Alexandrovich Kryukov
It depends on what you do. Asynchronous read certainly uses a bit more resources. But consider what happens if you use synchronous read. If all you code is sequential with the synchronous read in between, you really save some time. This is typical for some console application.When you need...
2 Jan 2012 by pavankumar from hyderabad
Hi AllI am pretty new to serial port communication Please help me out how to set port mode through c sharp.Thanks and regardsPavan Kumar
15 Jan 2012 by Richard MacCutchan
need a small app(vb/32bit) to run settings above.You could use one of the free terminal programs that Google will find for you (Hyperterm, putty etc), or you could write it yourself.
19 Mar 2012 by sweetly2012
I want to get the CD-ROM Drive Serial number that it is product SN display on the label .how to do use C# read ??
7 Apr 2012 by Synodiporos
Hello to everyone ...I have created an application and I want to communicate Serial with a external device. The device sends the data at unspecified period. For this reason I have written the following code: public string Read() { String DataReceived = ""; ...
7 Apr 2012 by Sergey Alexandrovich Kryukov
Nothing happens "automatically". You only read the data if you program it. If just need to grasp the idea of serial communications. It everything happened as you describe, working with the port would be nearly impossible. In reality, everything is much better. When one sides sends some data, you...
8 Apr 2012 by Synodiporos
Thanks for your answer!Ok I try to put the read call in a timer. private void timer_Serial_Tick(object sender, EventArgs e) { String read_fr = Read(); if(read_fr != "") richTextBox2.Text += read_fr; // . . . }Timer frequency (read) = 5ms
12 Apr 2012 by jitsejan
Hey all,After hours of browsing and reading, I still can't figure out why my code isn't working. I saw similar code snippets on different websites, but I can't seem to get it to work. The writing part is working, but the reading goes wrong. Every 'real character' is followed by three null...
12 Apr 2012 by nv3
Looks to me that the FPGA might not return your characters fast enough and you are running on the read timeout of 50ms. You might want to try two things:- reflect the characters by a loop-plug on your serial lineif that works fine- extend the ReadIntervalTimeout and...
12 Apr 2012 by Jochen Arndt
There must be a compiler warning for the ReadFile line because buffRead is nowhere initialized:char *line, *buffWrite, *buffRead;...if(ReadFile(hSerial, buffRead, BUFFERLENGTH, &dwBytesRead, NULL)){This can produce unpredictable results.
26 May 2012 by SoMad
I previously posted a response regarding general COM port functionality. I would like to make a suggestion regarding your program structure.There are obviously many ways of doing the data flow, but given your explanation, I would suggest that you change things around so the thread reading...
27 May 2012 by michaelmel
Your question is general hence the answer is a bit general too:1) Using a separate thread for receive is correct (incidentally, if you had to transmit as well, it should run in a separate thread)2) You should have a "raw" buffer that receives serial stream (not sure why you need the matrix...
26 Oct 2012 by mohammadali1375
Hi every body;I want some library or ... for simple connection with serial. I found sth but I cant use them.I want simple one. and I dont like use c++.netThanks
5 Nov 2012 by mohammadali1375
Hi.I wnat send data to windows ( or sth else ) with serial connection with usb cabel. can i do that ?
5 Nov 2012 by bEGI23
How long can a Service Tag be, is it even specified?
5 Jan 2013 by OriginalGriff
Without your code, it is impossible to be sure, but I would start by looking at your communication setup - make sure that your baud rate matches, your bits per character, parity and stop bits are correct also. I would also try wiring from one pc to another to confirm you are using the right port...
6 Jan 2013 by Trevor Johansen
Just a quick question. I have an app that uses mono and this app needs to communicate with something via a serial port at 256000 baud. I can connect to the hardware via "gtkterm /dev/ttyUSB0 250000" but in the mono app I do not get any errors or any communications at all.Someone mentioned...
15 Jan 2013 by Richard MacCutchan
I presume you are referring to Simple Serial Port Monitor[^], in which case, please post your question in the forum at the end of the article.
24 Feb 2013 by ÂĦmâd Ŝâlâĥ
i need to access in serial port what the code any one know about how ???in c# and win 7 32bit plz help
27 Mar 2013 by Pascal-78
SerialPort MSDN documentation here :http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.aspx[^]SerialPort comm = new SerialPort("COM1");// 9600,n,8,1comm.BaudRate = 9600;comm.Parity = Parity.None;comm.DataBits = 8;comm.StopBits = StopBits.One;//...
10 Apr 2013 by Bernhard Hiller
A boolean value is serialised to "false" or "true" - is it this what you want to change? - It does not work.If you want to change the name of the property, you can use the XmlElementAttribute:[System.Xml.Serialization.XmlElementAttribute("This_is_the_text_you_want_to_show")]public bool...
10 Apr 2013 by CPallini
In principle, you may always write you own serialization stuff (please note: writing a reliable serialization facility for all but very simple cases it is a quite difficult task): the most important property of serialization is reversibility: if you serialize an object then you have to be sure...
17 May 2013 by Sergey Alexandrovich Kryukov
How a serial port can depends on Metro style? Ever heard of separation of concerns?Check out: http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.aspx[^].—SA
27 May 2013 by Rddezh
Hi,I'm making a project, where I need to write to the serial port and read response from it as fast as possible. So I have written this code: serialPort.Open(); byte[] outBuf = new Byte[] { 59, (int)'4', (int)'3', (int)'1', 0, 0, 0 }; serialPort.Write(outBuf, 0,...
27 May 2013 by Liju Sankar
Could you please try these alternativesSerial Communication in C# Serial Communication in C#
15 Jun 2013 by zizu50
I have raspberry Pi . I use it as a server. I wanna get commands with clients (other devices like android devices) and control microcontroller with UART serial port. I wrote async TCP Socket server with mono C#. Like [this]. http://msdn.microsoft.com/en-us/library/fx6588te.aspxI can use UART...
30 Aug 2013 by Member 4347041
How to get the serial number, model,... of the usb key connected on to pc?Something like this: ManagementObjectSearcher USB = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive"); ManagementObjectCollection USBinfo = USB.Get(); string info = ""; ...
30 Aug 2013 by V.Lorz
Try querying for the WMI class Win32_LogicalDisk, it has one property called VolumeSerialNumber. Other properties like DriveType and MediaType will help you identifying the type or drive. With the property PNPDeviceID it could be possible to track it down to the physical USB device...
4 Oct 2013 by tstt91
Hey all!I wanna make program with activation code : xxxxx-xxxxx-xxxxx-xxxxx-xxxxxAnd the code have to limit day.(30 days,60 days.... bla bla)how do I have solved that problem?And this is a references i found: Application Trial Maker[^]
4 Oct 2013 by Mehdi Gholam
Remove the code that is doing the limiting, or just contact the author on the forum of that article.
6 Oct 2013 by mohsenvasefi
hi to everyonei want to connect via serial port and send/receive data. I've not done it before. I need to press on button(like as OK), then send data by port to a hardware. if it has an answer, send it to PC.how can i do this? please help me
7 Oct 2013 by the vacuum
I have to prepare a c/c++ program to send a audio file(*.wav file recorded from mic input) contents through serial port in windows(using API) and to receive it at a destination system through COM port itself . I have size (100kbps) constrains in the communication technology using to transfer....
8 Oct 2013 by Richard MacCutchan
Sending any data is exactly the same regardless of its source or type. You just need to read it in blocks of some appropriate size and transmit across the interface to the receiver PC. The receiver then either stores it in a file or sends it direct to the player software. Whether you can do this...
28 Oct 2013 by Member 10365929
Looking for a way to read and extract data from printer spooler - basic text.Printer is connected via parallel or usb or serial.Please help!
2 Jan 2014 by Xeshan Ahmed
Thank you for sharing your knowledge. Well I have enabled DtrEnable and RtsEnable now device is working fine. I have noticed that power LED was getting power from these signals. _serialPort = new SerialPort("COM3"); _serialPort.StopBits = StopBits.One; ...
16 Jan 2014 by caouchu
I work in the automation industry (for close to 30 years now) where serial communication protocols are still widely used. Most programmable logic controllers and remote telemetry units still make use of the Modbus RTU serial protocol. The BACNet MSTP (Master Slave Token Passing) is another...
16 Feb 2014 by glennPattonWork3
Hi There,Monday morning confusion again! In VB.Net (VS 2008) is WriteByte supported? MSDN says Yes,The Serial Port go-to book Serial Port Complete 2nd Ed by Jan Axelson says Yes, but the IDE reports WriteByte is not a member of 'System.IO.Ports.SerialPort'. One way I can do it is to...
10 Mar 2014 by varun mishra
Hello Everyone,I am not writing everything again here, because lot more depth is discussed at link below.Please help.Thx,-Varunhttp://social.msdn.microsoft.com/Forums/en-US/b65e4ff9-a7ce-4818-8e36-9db75fe8f49f/usb-serial-virtual-com-port-read-not-working?forum=vcgeneral[^]
10 Mar 2014 by bling
Try turning on the DTR pin. The device may ignore input when that pin is inactive.
17 Mar 2014 by glennPattonWork3
Hi All,I have some code I have written in C# and am having to convert it to VB.NET for a purpose. I am seeing some difference in the way VB handles the Data Received event. In C# as far as I can tell data arrives at the port, the flag is raised and the data is collected to be processed. I...
19 Mar 2014 by Mike Meinz
In VB.NET, you can add a Handles clause to a procedure and it will be recognized as the event handler. Private Sub port_DataReceived_1(ByVal sender As Object, _ ByVal e As SerialDataReceivedEventArgs) Handles AteComPort.DataReceived NoDataAtPort.Enabled = False ...
20 Mar 2014 by glennPattonWork3
Hi All,In my battle with VB I have no got solid reliable comms with the Unit Under Test.I can get it to reply to a rich text box, how ever I want to get the complete replyIf I monitor it in the below function Private Sub port_DataReceived_ATE(ByVal sender As Object, ByVal e As...