serial-port

Access serial port (/dev/tty*) incoming data without polling

安稳与你 提交于 2019-12-22 11:59:28
问题 I use Gingerbread. I already talk to a native serial port (RS-232 native UART, not USB dungle). This is done through java.io and a small piece of native code written in C to open and close the stream and configure the baudrate. It works but my first thought was that it is not efficient because I need to setup a thread that constantly poll the inputstream to check if there are bytes coming from the serial port. What a wasteful way to use CPU and batteries. private InputStream mInputStream;

Access serial port (/dev/tty*) incoming data without polling

╄→尐↘猪︶ㄣ 提交于 2019-12-22 11:58:03
问题 I use Gingerbread. I already talk to a native serial port (RS-232 native UART, not USB dungle). This is done through java.io and a small piece of native code written in C to open and close the stream and configure the baudrate. It works but my first thought was that it is not efficient because I need to setup a thread that constantly poll the inputstream to check if there are bytes coming from the serial port. What a wasteful way to use CPU and batteries. private InputStream mInputStream;

Send special characters to Serial Port

时光怂恿深爱的人放手 提交于 2019-12-22 10:46:12
问题 I have an application that allow exchange messages and I'm trying to send a string with special characters string my_str = "isto não está a funcionar! (pt)"; comPort1.Write(my_str); But I receive isto n?o est? a funcionar! (pt) . I tried to put comPort1.Encoding = Encoding.UTF8; before but it's not working yet. I tried diferent encodings. 回答1: If you write the encoded bytes of your string to the port, they will be sent correctly. This piece of code will do the trick for you: string my_str =

Serial message to integer on Arduino

筅森魡賤 提交于 2019-12-22 10:05:15
问题 I want my Arduino to receive an integer through the serial communication. Can you help me with this? It should be in a form like: int value = strtoint(Serial.read()); 回答1: There are several ways to read an integer from Serial , largely depending on how the data is encoded when it is sent. Serial.read() can only be used to read individual bytes so the data that is sent needs to be reconstructed from these bytes. The following code may work for you. It assumes that serial connection has been

how can i access serial port data in c++ using wxwidgets

↘锁芯ラ 提交于 2019-12-22 09:55:34
问题 i am electronics and communication engineering student. i am working on a project in which a microcontroller send data to serial port of computer (asynchronously). i currently learning wxWidgets for my GUI work. my question- is it possible to do using wxWidgets to get data and display. is it very difficult to implement this. i search for it but not get direct answer that how to implement this. so suggest me what i need to read for this. and what alternative available to do this. i use windows

xcode, c++ serial port with arduino

亡梦爱人 提交于 2019-12-22 09:48:40
问题 i’m making a very simple c++ program which send an angle to arduino through a serial port and then arduino apply that angle to a servo-motor. I know that Unix see serial ports device like a file, in fact this is the c++ code: #include <iostream> #include <unistd.h> using namespace std; int main() { int angole; FILE * arduino; do { arduino = fopen("/dev/tty.usbmodem3a21","w"); cout<<"\n\give me the angle\n\n"; cin>>angole; fprintf(arduino,"%d",angole); sleep(1); }while(angole>=0 && angole<=179

How to send serial data from Python script to Arduino on Windows - Nothing Works

岁酱吖の 提交于 2019-12-22 09:28:45
问题 I can't correctly send data over serial from a Python script to an Arduino Uno. I'm using 9600 baud, and the Arduino correctly resets, but it does not read the char I'm sending from the Python script. I call time.sleep() to ensure the reset on the Arduino does not interfere, and I'm using Windows 7. I should clarify by saying that my desktop is running the python script and connected via USB to the Serial of my Arduino Uno. I then have the RX & TX pins (pins 0 & 1) of my Uno connected to my

C++ Linux (Ubuntu) Writing to Serial Properly (For Arduino)

纵然是瞬间 提交于 2019-12-22 09:14:01
问题 I'd like to know if there is a standard way to communicate with the serial device that is efficient. Should I be using a standard library? If so, which one? Right now I'm fiddling around getting an LED to light up at a given amount based on number input. (Arduino code below). Just practice stuff. See my overly simple and inefficient test: #include <iostream> #include <stdio.h> using namespace std; int main() { FILE *file; //Opening device file int getnum; while (true) { file = fopen("/dev

How to write on serial port using Qextserialport

▼魔方 西西 提交于 2019-12-22 08:48:51
问题 I am using Ubunt 10.10. I want to communicate with a microcontroller (ATmega328p) using serial through QT, so for testing I have created a dummy application on the microcontroller that reads character from the UART and responds on the serial port (replies) with the same character but in between brackets. If PC send: a , then PC receives reply [a] The application is working great, when I am using hyper terminal (GtkTerm) to send the characters from PC, but when I use QT it does not work. I am

Sending bytes to serial port from UNIX command line?

孤人 提交于 2019-12-22 08:36:21
问题 i would like to send a stream of bytes to a serial port using the command line. is this possible? my serial port is at /dev/cu.usbserial-A700dYoR on my Mac. for example, if i wanted to send the integer 50 or the string "data" to that serial port, how can i do that? my knowledge of UNIX is very limited. 回答1: #!/bin/bash # Port setting stty -F /dev/cu.usbserial-A700dYoR raw speed 9600 echo 'Hello' > /dev/cu.usbserial-A700dYoR or something like that if I remember correctly... Been a few years.