serial-port

Serial port programming in Linux

不羁岁月 提交于 2019-12-22 01:05:27
问题 I want to use RS232 port on the board to communicate with a PC. I understand that I can use "dev/ttyS0" for that purpose. I can open and write data to PC by using write() function. But the problem is I can't read from "dev/ttyS0". Every time I use read function, I get "Resource temporarily unavailable". Can u guys tell me how to solve this problem? Here is my code: #include <stdio.h> #include <string.h> #include <fcntl.h> #include <termios.h> #include <unistd.h> int main() { int n = 0, fd = 0

UWP serial port communication for character write and read (UWP and Arduino)

孤街醉人 提交于 2019-12-22 00:20:52
问题 I am using this code but not working and throwing this exception: Object reference not set to an instance of an object devices[0] giving me null value. private async void ConnectToSerialPort() { string selector = SerialDevice.GetDeviceSelector("COM7"); DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(selector); if (devices.Count > 0) { DeviceInformation deviceInfo = devices[0]; SerialDevice serialDevice = await SerialDevice.FromIdAsync(deviceInfo.Id); Debug.WriteLine

get serial com port description in windows batch

一曲冷凌霜 提交于 2019-12-22 00:05:05
问题 I want to retrieve serial com port information as device manager shows. For example, "Intel(R) Active Management Technology - SOL (COM3)". I know use command "mode" to retrieve serial port list, but there is no description like "Intel(R) Active Management Technology - SOL". How do I get this information in windows batch file? 回答1: Updated answer ... was provided by the original asker in the comments below. Apparently Win32_SerialPort doesn't include USB->Serial devices. William's solution to

RS232 question - how to read weight to PC

我是研究僧i 提交于 2019-12-21 23:13:40
问题 I have a scale that connect to PC through RS232, I send "W" to receive the weight. The scale sends the weight all the time as it's read. How do I catch the weight that is being read? Can i get any C# sample code? 回答1: Sending a W? Sounds like the Mettler Toledo scale that FedEx gives businesses. I happen to have some code that reads from such a scale: // where this.port is an instance of SerialPort, ie // this.port = new SerialPort( // portName, // 1200, // Parity.None, // 8, // StopBits.One)

“Cross thread operation not valid” .. while reading data on Serial Port

偶尔善良 提交于 2019-12-21 21:37:04
问题 In a windows form application, on main form load, i have set a serial port and started reading it. The purpose is, as and when I receive some data on the serial port, I want to open another form related to the data. So i use the DataReceived Event Handler of the serial port. void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { string str = this.serialPort1.ReadLine(); if (!string.IsNullOrEmpty(str)) { Main.Instance.customerData = new CustomerData(str);

Reading a Serial Port Asynchronously Boost

寵の児 提交于 2019-12-21 20:44:21
问题 I am trying to read several bytes asynchronously from a serial port. Currently the code I am using (source is How do I perform a nonblocking read using asio?), only allows me to read 1 byte and then it exits. How do I get it so that the code keeps reading until there is no more incoming data in the serial port? Thanks :) void foo() { boost::asio::io_service io_svc; boost::asio::serial_port ser_port(io_svc, "/dev/ttyS0"); boost::asio::deadline_timer timeout(io_svc); unsigned char my_buffer[2];

Python3 Two-Way Serial Communication: Reading In Data

删除回忆录丶 提交于 2019-12-21 20:09:57
问题 I am trying to establish a two-way communication via Python3. There is a laser range finder plugged into one of my USB ports and I'd like to send/receive commands to that. I have a sheet of commands which can be sent and what they would return, so this part is already there. What I need is a convenient way to do it in real-time. So far I have the following code: import serial, time SERIALPORT = "/dev/ttyUSB0" BAUDRATE = 115200 ser = serial.Serial(SERIALPORT, BAUDRATE) ser.bytesize = serial

Access native serial port on Android

房东的猫 提交于 2019-12-21 17:05:00
问题 I want to give android application/service access to native serial port (UART RS-232). When I say native, I mean a real UART not a USB to serial dongle. I can see them from the terminal (connected to one of the 4 native serial port). It shows that kernel already takes care of the low level stuff. # ls -l /dev crw-rw-rw- system system 204, 67 2010-01-01 07:00 s3c2410_serial3 crw-rw-rw- system system 204, 66 2010-01-01 07:00 s3c2410_serial2 crw-rw-rw- system radio 204, 65 2010-01-01 07:00

Can send/Can't read .NET serial port [duplicate]

狂风中的少年 提交于 2019-12-21 14:11:32
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: C# serialport and hyperterminal Problem I'm having trouble with my serial connection. I can send data to my device, but I can't read data. If I use Hyperterm, everyting work fine - I see the data coming in and going out. Using my code, however, my serial port object never receives any data, but data I send is received by the device. Any ideas? Project Info: WPF .NET 3.5 (not the Client Profile version)

Unable to sync computer time to Arduino via USB

白昼怎懂夜的黑 提交于 2019-12-21 09:23:20
问题 I want to sync the Time from my pc to the arduino. I am using their Time library but it does not work. How can I get the arduino to have the same time as on my computer ? I am currently using a mac. Their documentations says : On a unix system, you can set the time with the shell command: TZ_adjust=-8; echo T$(($(date +%s)+6060$TZ_adjust)) > /dev/tty.usbserial-A8008pym I tried on the terminal >export TZ_adjust=-8; echo T$(($(date +%s)+6060$TZ_adjust)) > /dev/tty.usbmodemfd131 and I get