serial-port

convert serialport.readline() non-ascii string into a byte array

╄→尐↘猪︶ㄣ 提交于 2019-12-24 20:36:57
问题 I want to use serialport.readline() because it's a blocking call and the data I'm getting has 0x0D 0x0A (CR LF) at the end. However, what I want is an Hex String instead of an Ascii representation. For example, the device I am communication with is sending byte arrays like {0xff,0xff,0x45,0x0D,0x0A}. I want to simply print out in my program just like this: 0xff, 0xff,0x45. Readline() kindly trims out LF and CR. I though about using serialport.read(buff[]...) by specifying how many bytes I

Read and write serial port on Linux

我的未来我决定 提交于 2019-12-24 20:28:31
问题 I use github.com/jacobsa/go-serial/serial package to work with serial port in my Go program. Simplified example: options := serial.OpenOptions{ PortName: "/dev/ttyUSB0", BaudRate: 115200, DataBits: 8, StopBits: 1, MinimumReadSize = 0, InterCharacterTimeout = 100, } port, _ := serial.Open(options) defer port.Close() res := make([]byte, 1024) var err error var i int = 0 for i == 0 { i, err = port.Read(res) if err != nil && err != io.EOF { log.Printf("port.Read: %v", err) err = errors.New("I/O

chat on assembly using serial port

五迷三道 提交于 2019-12-24 20:28:27
问题 I'm working on a chat using assembly and i got this huge doubt, I'm currently using int 21, AH= 0Ah to get a string from the keyboard wich I will later send, char by char, through the serial port, but then i was wondering how, will I receive a msg from the other computer running the same program if this one is in a interruption waiting for me to input a string. How can i get around the fact that when inputing a string, the whole program is interrupted and anything being sent on the mean time

Boost asio serial port initially sending bad data

浪尽此生 提交于 2019-12-24 20:13:19
问题 I am attempting to use boost asio for serial communication. I am currently working in Windows, but will eventually be moving the code into Linux. When ever I restart my computer data sent from the program is not what it should be (for example I send a null followed by a carriage return and get "00111111 10000011" in binary) and it is not consistent (multiple nulls yield different binary). However, as soon as I use any other program to send any data to the serial port and run the program again

SerialPort.ReadLine() slow compared to manual method?

自作多情 提交于 2019-12-24 19:41:24
问题 I've recently implemented a small program which reads data coming from a sensor and plotting it as diagram. The data comes in as chunks of 5 bytes, roughly every 500 µs (baudrate: 500000). Around 3000 chunks make up a complete line. So the total transmission time is around 1.5 s. As I was looking at the live diagram I noticed a severe lag between what is shown and what is currently measured. Investigating, it all boiled down to: SerialPort.ReadLine(); It takes around 0.5 s more than the line

Sending Hex value in win32 not working similar to c++ code

泄露秘密 提交于 2019-12-24 19:28:27
问题 I have c++ code as follows to display hex value from int array. #include <iostream> using namespace std; int main() { int binText[32]={1,0,1,0,1,1,1,1,0,0,0,1,1,0,1,0,1,1,1,1,0,1,0,1,1,1,1,1,0,0,0,1}; char temp[255]={0}; for (int i=0; i<32; i++) { sprintf(&temp[strlen(temp)], "%d", binText[i]); } char HexBuffer[255]; unsigned long long int Number = 0; int BinLength = strlen(temp); for(int i=0; i<32; i++) { Number += (long int)((temp[32 - i - 1] - 48) * pow((double)2, i)); } ltoa(Number,

Using Serial Peripheral Interface (SPI) to talk to several slaves simultaneously

回眸只為那壹抹淺笑 提交于 2019-12-24 17:16:08
问题 I have four Atmega328p in a single board and I want one of them send the same data (i.e. sensor readings) to the other three simultaneously. I'm not interested in a bidirectional communication. I read this thread (How can I broadcast data to multiple SPI slaves and how it works?) about SPI broadcasting, and someone mentioned not being possible because in SPI communication is full duplex and MISO and MOSI lines are active at the same time. However, I was wondering if I could just let the MISO

How to print in Arduino a char variable as a number to the Serial Port?

两盒软妹~` 提交于 2019-12-24 17:00:13
问题 I am using Arduino Uno. I am reading a byte value from the EEPROM and storing the value in a variable of type char (1 byte). I want to print the value of the variable as a number (not to the corresponding ASCII code) to the Serial Monitor. For example consider char val = 5 . I want to see to the Serial Monitor 5 and not the ASCII value. I tried both Serial.print(val) and Serial.write(val) but the result is the same: it prints always the ASCII code. How can I print the value to the Serial

Serial Port reading HEX data and insert in the separate textboxes (Book RFID Hex & User RFID Hex)

我的未来我决定 提交于 2019-12-24 16:42:42
问题 GUI of Project [ In this image I am using UHF reader's software for testing of RFID cards so my end result in the textboxes should be unique 12-byte HEX of RFID card [ (image 2 preview) Basically, I am working on Library Management System(LMS) project & I am trying to issue books by using the User identity ( User RFID Tag ID in HEX ) and Book identity ( Book RFID Tag ID in HEX ). When user will come in the library for issue a book then he/she will swipe his/her RFID card as a result user ID

Root permission to configure UART1 in Beaglebone [closed]

北战南征 提交于 2019-12-24 14:16:38
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I use a Beaglebone black, which runs on Android, in a project I work. I need to use UART1. As I understand I have to configure the MODE of UART1. It must be MODE0. I can do it via adb with these command: echo 20 > /sys/kernel/debug/omap_mux/uart1_rxd echo 0 > /sys/kernel/debug/omap_mux/uart1_txd Everything works