serial-port

Change SerialPort's BaudRate while connection is open

廉价感情. 提交于 2019-12-19 17:39:06
问题 I am using SerialPort class to communicate with an external device. I start the communication at 300 Baud per second however after the initial "handshake" I have to switch to a Baud rate specified by the device (usually 9600 Bps). I have been unsuccessful in my attempts to continue communicating after I increase Baud rate however I am not sure why. That leads me to my question: What is the proper way of changing the Baud rate? Can it be done while the connection is open, or should I close the

How to wait for COM port receive event before sending more data in a loop

吃可爱长大的小学妹 提交于 2019-12-19 11:35:49
问题 I'm working on a small component for writing and reading AT Commands using an old Sony Ericsson phone. Sending and writing to/from the phone is no problem at all, however I would like to be able to pause my SendATCmd function and wait for the COM Port component to notify me with a Notification Event, and then resume the SendATCmd function again. Scenario: I want to get the count of SMS messages in the phone. Normally I'd just tell the phone: Hey, how many SMS messages do you have? and the

Sending a voltage to RS232

岁酱吖の 提交于 2019-12-19 10:40:39
问题 I know that we can use pin no.3 to send the data as a output in RS232. But I am just wondering that there is another way to send only the voltage 5v to the RS232 in a short period? I just want that 5v to trigger a PIC Microcontroller to do something. Thank you in advance. 回答1: You could use the DTREnable (Data Terminal Ready) property of the SerialPort class to apply a positive voltage to those respective pins. This could be used to signal an MCU. Something along the lines of... serialPort

What causes my UI to freeze when closing a serial port?

妖精的绣舞 提交于 2019-12-19 10:08:49
问题 I am working on a serial port related application. While using DataReceived event of SerialPort I need to update a textbox with the received bytes: private void Connection_DataReceived(object sender, SerialDataReceivedEventArgs e) { var data = Connection.ReadExisting(); _readBuffer.Add(indata); Invoke(new EventHandler(AddReceivedPacketToTextBox)); } So I use Invoke to update the textbox. But there is a big problem. When I try to close connection, my UI gets freezed, I think this is becase

How to transmit a String on Arduino?

喜夏-厌秋 提交于 2019-12-19 10:06:10
问题 I want 2 Arduinos Leonardo to communicate, send a string for instance, so I have to use Serial1 to communicate via RS232 on pins 0 (RX) and 1 (TX). I need to write binary data in that pins, the problem is how can I send a String using Serial1.write . Serial1.print works without errors but I think it does not do what I want. Any suggestion? void setup() { Serial.begin(9600); Serial1.begin(9600); while (!Serial); // while not open, do nothing. Needed for Leonardo only } void loop() { String

Electron and serial ports

好久不见. 提交于 2019-12-19 09:55:44
问题 I have tried everything to try to get Electron to work with the PCs serial port. Followed all instructions for the serialport (even tried building native modules) without luck. Has anyone had any luck getting Electron to work with serial ports? If so please share your wisdom. 回答1: Here are the commands we run after doing npm install (or after upgrading electron or node-serial). on Mac rm -rf node_modules/serialport/build/* node_modules/.bin/electron-rebuild -w serialport -f ls node_modules

Why fcntl(fd, F_SETFL, 0) use in serial port programming

流过昼夜 提交于 2019-12-19 09:09:17
问题 I am starting serial port programming in Linux. After reading several examples on the web, I don't understand exact effect of fcntl(fd, F_SETFL, 0) ? It is clearing bits, but what flags does it affect? What does it set and or clear? 回答1: Take one by one 1) Function call used fcntl() - It perform the operation on file descriptor passed in argument. 2) 2nd argument in call F_SETFL (int) Set the file status flags to the value specified by arg. File access mode (O_RDONLY, O_WRONLY, O_RDWR) and

Sending serial communication from Raspberry pi

十年热恋 提交于 2019-12-19 08:11:10
问题 I am sending serial data from a Raspberry Pi to an Arduino using a Python program. I am running Python 2.7.3. The program is: import serial ser = serial.Serial('/dev/ttyACM0', 115200) ser.write(b'\x4c\xff\x46') The problem is that nothing seems to be sent by these three lines if they are run in a program. But if I run them line by line in a Python shell, they work fine. Also, if I have the Arduino Serial Monitor open, the program works fine as well, without running the lines one by one in the

reading from barcode scanner

你离开我真会死。 提交于 2019-12-19 07:11:51
问题 I need to read data from barcode scanner in a web page. I agree that a usb scanner or a scanner equipped with keyboard wedge driver could get the data to a text field in the web page. I'm curious to know how do we read the data from RS-232 based scanner and bluetooth scanner. Will they also get the data to a textfield in a web page without any extra effort? If not, how do I accomplish that? 回答1: Yes, if you're scanning into a webpage form (and not your own desktop app), you need to have some

Sending ctrl+C over serial port in C#?

妖精的绣舞 提交于 2019-12-19 04:55:13
问题 How can I send my device ctrl + c through serial port in C#? 回答1: Serial ports don't transmit keys. They transmit bytes, which are normally the ASCII representations of characters. "Keys.ControlKey & Keys.C" has to do with sensing what is going on on a PC keyboard. But serial ports do not transmit the whole state of the keyboard. For instance, the F keys and the arrows are entirely outside the ASCII system. An ASCII chart will tell you that, for instance, Ctrl - A is 1, Ctrl - B is 2, Ctrl -