serial-port

Storing string from arduino to text file using python

蹲街弑〆低调 提交于 2019-12-13 15:35:13
问题 I am using this code to send a string from arduino to PC int i=0; void setup(){ Serial.begin(9600); // Open serial connection at a baud rate of 9600 pinMode(13, OUTPUT); //set pin13 in o/p mode } void loop(){ while(1) { Serial.write("10.028371,76.328873"); Serial.write('\0'); delay(1000); } } I need a python code that receives this string and store it in a text file as such.The arduino is transmitting this string continuously but i need it only once in the text file. I have written the below

How to find a Serial port device in .NET with its driver name?

对着背影说爱祢 提交于 2019-12-13 15:31:40
问题 I have a device that connects to the computer through serial port. I understand to open the port in .NET I can call the port by COM number. For example SerialPort s = new SerialPort("COM9"); s.Open(); calls the device on COM9. However, if I run my program and serial port device on another computer port number could be changed, yet the device name is always the same on every computer. For example in this picture I would like to communicate with "Numato Lab 8 Channel USB Relay Module"

CRC calculation in Java

别来无恙 提交于 2019-12-13 15:22:29
问题 I'm reading a file from serialport using x-modem protocol and 133 bytes packet. I'm reading in that 1 byte is SOH 2 byte packet number 3 byte nagative of packet number next 128 bytes data 2 bytes CRC sent from other side. I have to calculate CRC of 128 bytes data and 2 bytes crc sent from other side that I have to make it single byte and have to comapare with my calculated crc. How can I do this in java? 回答1: Try using Jacksum. 回答2: Sun JDK 1.6 contains sun.misc.CRC16, but there is a

Arduino Serial Communication not receiving entire message

ⅰ亾dé卋堺 提交于 2019-12-13 15:19:14
问题 I have a problem with the Arduino communication. It's quite hard to describe so I cant fit it in the title. Anyway here are the following: So I have this code for my receiving end: if(Serial1.available()) { while(Serial1.available()) { uint8_t inByte = Serial1.read(); inByte = inByte ^ k; Serial.write(inByte); } Serial.println(" done"); } It's supposed to print in one line and print done when it's done. The Serial1.available() seems to skip the next Serial1.available() , I don't know what's

Setting serial RS232 port settings; any in C# alternatives to SerialPort class?

我们两清 提交于 2019-12-13 15:18:37
问题 In my .NET application I need to achieve serial port setup equivalent to this C++ managed code: ::SetCommMask(m_hCOMM, EV_RXCHAR); ::SetupComm(m_hCOMM, 9*2*128*10, 400); ::PurgeComm(m_hCOMM, PURGE_TXABORT|PURGE_RXABORT|PURGE_TXCLEAR|PURGE_RXCLEAR); COMMTIMEOUTS timeOut; timeOut.ReadIntervalTimeout = 3; timeOut.ReadTotalTimeoutConstant = 3; timeOut.ReadTotalTimeoutMultiplier = 1; timeOut.WriteTotalTimeoutConstant = 0; timeOut.WriteTotalTimeoutMultiplier= 0; int nRet= ::SetCommTimeouts(m_hCOMM,

How do you flush a Java serial InputStream?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 14:39:29
问题 I'm using JavaComm, and getting the inputStream from the serial port object. I have a problem in that sometimes when the system starts up there are noise characters in the buffer that I do not want. I want to initialize the serial port then somehow flush the input of all data before I begin my processing. Is there any way to do that? TY Fred 回答1: How would a "flush()" method know what is garbage and what is real data? Only you know, and your program should be prepared to ignore leading

Sending (serial) break using windows (XP+) api

送分小仙女□ 提交于 2019-12-13 14:32:41
问题 Is there a better way to send a serial break then the setcommbreak - delay - clearcommbreak sequence? I have to communicate with a microcontroller that uses serial break as the start of a packet on 115k2, and the setcommbreak has two problems: with 115k2, the break is well below 1ms, and it will get timing critical. Since the break must be embedded in the packet stream at the correct position, I expect trouble with the fifo. Is there a better way of doing this, without moving the serial

Creating a Serial Port in code in VB.net

时光毁灭记忆、已成空白 提交于 2019-12-13 11:43:48
问题 I am trying to create a serial port in VB.net using code only. Because I am creating a class library I cannot use the built-in component. I have tried instantiating a new SeialPort() object, but that does not seem to be enough. I'm sure there is something simple I am missing and any help would be greatly appreciated! Thanks! P.S. I should add that the problem I am having at this time is getting the code to handle the datareceived event. Other than that it might be working, but I can't tell

How to send ASCII values greater than 127 to serial port

拜拜、爱过 提交于 2019-12-13 09:13:20
问题 Whenever i send any ASCII value greater than 127 to the com port i get junk output values at the serial port. ComPort.Write(data); 回答1: Strictly speaking ASCII only contains 128 possible symbols. You will need to use a different character set to send anything other than the 33 control characters and the 94 letters and symbols that are ASCII. To make things more confusing, ASCII is used as a starting point for several larger (conflicting) character sets. This list is not comprehensive, but the

What's the maximum baud rate in MATLAB?

99封情书 提交于 2019-12-13 08:59:35
问题 Ubuntu 16.04 & MATLAB R2017a. I'm trying to set serial port like that: s=serial_port('/dev/ttyUSB0','BaudRate',115200,'DataBits',8,'InputBufferSize',80000) It's working fine, but when I try to change baud rate, say 1000000. I got this message: Open failed: BaudRate could not be set to the specified value. So, I have 2 question: 1) Is it possible to set not common baud rates, say 2000000? 2) I found, that 1500000 and 3000000 is working for me. Is there maximum speed? ** UPDATE** I know how to