serial-port

Serial port communication display

我怕爱的太早我们不能终老 提交于 2020-01-04 09:08:05
问题 I'm trying to make a chat with serial port communication. This chat has to have an interface in a WPF Project, I already made my interface and everything. I'm stuck in receiving the response through the serial port. I already tried adding a DataReceived event from the serial port but I'm afraid I'm using it wrong since I have never programmed in C# before. It is a really simple code. What I need to do is receive the information from the serial port and display it in a text block as it would

Java : threaded serial port read with Java.util.concurrent thread access

喜欢而已 提交于 2020-01-04 09:04:24
问题 I'm trying to write a Java serial device driver and want to use the (new to me) java.util.concurrent package. I have one method which sends a packet then waits for an ACK. I plan to have char. reception run in a different thread. If the receive thread gets an ACK it should notify the thread with the send packet function. The receive thread implements a state machine and should notify any listeners of decoded packets. I think I know how to do this using direct Threads, wait , notify etc., but

How do I reset my Arduino Mega2560 with my C# application?

╄→гoц情女王★ 提交于 2020-01-04 07:20:02
问题 I noticed the Arduino IDE automatically resets on startup/exit by the built in serial application due to one of the hardware flow control lines (DTR) of the FT232RL is connected to the reset line of the ATmega1280 via a 100 nanofarad capacitor. When this line is asserted (taken low), the reset line drops long enough to reset the chip. I noticed that behaviour does not happen with my serial C# application. I would like the reset feature to work with my C# application. What am I not doing to

MacPython: programmatically finding all serial ports

喜夏-厌秋 提交于 2020-01-04 04:03:44
问题 I am looking for a solution to programmatically return all available serial ports with python. At the moment I am entering ls /dev/tty.* or ls /dev/cu.* into the terminal to list ports and hardcoding them into the pyserial class. 回答1: You could do something like this: import glob def scan(): return glob.glob('/dev/tty*') + glob.glob('/dev/cu*') for port in scan(): # do something to check this port is open. Then, take a look at pyserial for some good utility functions to check if a port is

Unable to Read From Serial Device After Unplugging and Replugging Connector

主宰稳场 提交于 2020-01-03 20:05:35
问题 I'm have a Linux application that is supposed to read from serial device /dev/ttyS0 . The serial device is opened in the following manner: // Open the serial port if((serial_device = open("/dev/ttyS0", O_RDWR | O_NOCTTY)) < 0){ fprintf(stderr, "ERROR: Open\n"); exit(EXIT_FAILURE); } // Get serial device attributes if(tcgetattr(serial_device,&options)){ fprintf(stderr, "ERROR: Terminal Get Attributes\n"); exit(EXIT_FAILURE); } cfsetspeed(&options,speed); // Set I/O baud rates cfmakeraw(

Unable to Read From Serial Device After Unplugging and Replugging Connector

筅森魡賤 提交于 2020-01-03 20:05:34
问题 I'm have a Linux application that is supposed to read from serial device /dev/ttyS0 . The serial device is opened in the following manner: // Open the serial port if((serial_device = open("/dev/ttyS0", O_RDWR | O_NOCTTY)) < 0){ fprintf(stderr, "ERROR: Open\n"); exit(EXIT_FAILURE); } // Get serial device attributes if(tcgetattr(serial_device,&options)){ fprintf(stderr, "ERROR: Terminal Get Attributes\n"); exit(EXIT_FAILURE); } cfsetspeed(&options,speed); // Set I/O baud rates cfmakeraw(

Accessing COM10 or greater port in C#

自作多情 提交于 2020-01-03 14:14:47
问题 I am using Visual Studio 2010 and programing in C# (.NET 3.5). I want to write/read data from COM10. Here is the simple code for that: static void Main(string[] args) { String Portname = String.Empty; /* List out all COM ports present on the computer. */ foreach (string ports in SerialPort.GetPortNames()) { Console.WriteLine(ports); /* If COM10 exists, copy the name for further use. */ if (ports == "COM10") { Portname = ports; //I also tried this: "\\.\\COM10"; } } /* If COM10 not found,

.Net SerialPort taking over 0.5 seconds to read byte when bytes available

柔情痞子 提交于 2020-01-03 08:58:27
问题 I'm using the .Net SerialPort class in C# to read bytes from a port. On receipt of a DataReceived event I check the serial port to see if bytes are available to be read. However, even if bytes are available, the port can take over half a second to read a single byte. Code is roughtly as follows: ... while(Port.BytesToRead > 0) { StopWatch.Restart(); Int32 BytesRead = Port.Read(Read, 0, 1); StopWatch.Stop(); if (StopWatch.ElapsedMilliseconds > 100) { // Record the time. The stopwatch code //

Using same serial port instances on multiple forms

霸气de小男生 提交于 2020-01-03 06:37:10
问题 I am quite new to C# and I am trying to use one common serial port for 3 different forms: Form2, Form3, Form4 Form1.cs isn't needed for this because it's just needed to launch the programs of the other forms. Basically, all 3 forms must receive data from the same serial port at the same time. The problem I am facing is that only one form can receive data from the serial port, but the other two forms can't. I found a question similar to this: Using same serial port data received event on two

Interrupting a for loop while receiving data from a serial port

倖福魔咒の 提交于 2020-01-03 06:27:11
问题 How can I make my program interrupt an already running for loop when it receives the "K" character from a serial port ? The code is : import serial from time import sleep ser = serial.Serial(port='/dev/ttyUSB0',baudrate=9600,parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE,bytesize=serial.EIGHTBITS,timeout=0) while 1: for line in ser.read(1): input+=chr(line) if input == 'S': for x in range (1 , 10): # this is the loop i want to break print(x) sleep(1) if input == 'K': print('K received