serial-port

Receiving messages part by part from serial port using c#

大憨熊 提交于 2019-12-31 04:59:06
问题 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 getting the messages part by part. Like, if u send "Hello, How are you" I am receiving it word by word. I want that in a single stretch. How can i do ?? Also, is it possible to retrieve the port name from which the application

SerialPort encoding - how do I get 8 bit ASCII?

人走茶凉 提交于 2019-12-31 04:57:06
问题 I'm having a problem with a program that communicates over a serial port. One of the characters it must send and receive is the degree symbol, ASCII 0xBF. It's been working fine for years now suddenly the serial port object has started dropping bit 7, so I get 0x3F instead of 0xBF. I'm sure that this is something silly I've done because I've tinkered with my code in that area recenlty - however I cannot see what I've done that causes loss of the 8th bit. My port gets initialized like this:

Unix: How to clear the serial port I/O buffer?

喜夏-厌秋 提交于 2019-12-31 04:52:06
问题 I am working on a "high level" C++ interface for the standard PC serial port. When I open the port, I would like to clear the input and output buffers in order not to receive or send data from previous usage of the port. To do that, I use the tcflush function. However, it does not work. How can that be? My "port opening" code can be seen below. Yes I use C++ exceptions but none are getting thrown. That indicates that tcflush returns 0 but it does not clear the buffer. The only way I can clear

Only one byte is read when reading just now opened SerialPort

三世轮回 提交于 2019-12-31 03:18:49
问题 Strange issue. When I read from com-port with SerialPort.Read(), then if data arrive, only one byte is read on the first call , disregards of count parameter and number of bytes available within timeout. All further readings are ok, only very first has problem Using SerialPort.DiscardInBuffer() or close/open (reopen) com-port will again cause the problem of the first reading. Here is some code: var port = new SerialPort(); port.PortName = "com2"; port.BaudRate = 9600; port.WriteTimeout = 1000

How to read from a serial port in lua

耗尽温柔 提交于 2019-12-30 18:54:08
问题 I'm new to lua and I'm trying to receive data from the port, ttyACM0, I can write to the port by: wserial = io.open("/dev/ttyACM0","w") wserial:write("hellloooo") wserial:flush() I thought since I can write to it in the same way as I would write to a file that I could read it in the same way as I would read a file. But when I try to read it (using the code below) I just end up in an infinite loop. rserial=io.open("/dev/ttyACM0","r") while chaine==nil do chaine=rserial:read() rserial:flush()

Why do the outputs differ when I run this code using NetBeans 6.8 and Eclipse?

对着背影说爱祢 提交于 2019-12-30 10:57:49
问题 When I am running the following code using Eclipse and NetBeans 6.8. I want to see the available COM ports on my computer. When running in Eclipse it is returning me all available COM ports but when running it in NetBeans, it does not seem to find any ports .. public static void test(){ Enumeration lists=CommPortIdentifier.getPortIdentifiers(); System.out.println(lists.hasMoreElements()); while (lists.hasMoreElements()) { CommPortIdentifier cn=(CommPortIdentifier)lists.nextElement(); if (

Serial Port (RS232) communication with Visual C++ 2010

非 Y 不嫁゛ 提交于 2019-12-30 07:50:44
问题 I have to write a program in Visual C++ 2010 to communicate via Serial Port (RS232) in Windows 7 32 bit. Can Someone help me to find correct example? 回答1: Serial Communications: http://msdn.microsoft.com/en-us/library/ff802693.aspx This article still remains actual after so many years... Code sample included. 回答2: Here it is a two samples of the same program, one for visual studio 2013 and the other for minGW in Eclipse in Windows 7 32 bits for visual studio: stadfx.h #pragma once #include

How to deal with multiple serial ports for R/W using twisted?

五迷三道 提交于 2019-12-30 06:45:04
问题 Going through the twisted finger tutorial and seen the SO questions: Question-1 Question-2 However, I can't (yet) write a twisted program that can read & write from multiple serial ports, especially where the protocol involves reading single or multiple lines, and writing back to the device accordingly. What I am trying to do is open 2 pairs (i.e. total of 4) serial ports, for 2 modems. Communication with modems is using Hayes AT command set. While most of the command/response exchanges with

Finding USB serial ports from a .NET application under Windows 7

家住魔仙堡 提交于 2019-12-30 05:01:08
问题 I have an application that looks for a specific FTDI serial port with customised USB descriptors. My current code uses the example from Code Project, which searches the MSSerial_PortName WMI table under root\WMI , and pulls out extra USB information from root\CIMV2\WIN32_PnPEntity . This worked well under XP, but the application must also run under a standard user onWindows 7. In this environment access of root\WMI results in an "Access Denied" ManagementException . Can anybody suggest a way

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

流过昼夜 提交于 2019-12-30 03:28:24
问题 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