serial-port

Getting device/driver information related to a COM port?

こ雲淡風輕ζ 提交于 2019-12-28 13:51:02
问题 I have a Serial-to-USB device with a similarly named device driver in the Windows device manager. The devices do not always grab the same COM port on system boot, so my program needs to identify it on start up. I've tried using RXTX to enumerate the COM ports on the system, but this didn't work because CommPortIdentifier.getName() simply returns the COM name (eg. COM1, COM2, etc.) I need to acquire either the driver manufacturer name, or the driver name as it appears in the device manager,

why is access to com port denied?

前提是你 提交于 2019-12-28 06:43:06
问题 the code: static void Main(string[] args) { Console.WriteLine("Memory mapped file reader started"); using (var file = MemoryMappedFile.OpenExisting("AIDA64_SensorValues")) { using (var readerz = file.CreateViewAccessor(0, 0)) { var bytes = new byte[567]; var encoding = Encoding.ASCII; readerz.ReadArray<byte>(0, bytes, 0, bytes.Length); File.WriteAllText("C:\\myFile.txt", encoding.GetString(bytes)); var readerSettings = new XmlReaderSettings { ConformanceLevel = ConformanceLevel.Fragment };

Force a COM port to close

假装没事ソ 提交于 2019-12-28 04:18:09
问题 I'm working on an application that uses COM port for communication with external controller. When I reboot the PC with communication cable connected, Windows (7) opens the port, without any application running, so I can't access it any more. I tried to close it programatically, but it just stays taken. Anyone got an idea how can I force it to close, any program I can run before my app, or a way to programatically close it no matter what? 回答1: I didn't manage to close the port, but after a lot

Converting serial port data to TCP/IP in a Linux environment

前提是你 提交于 2019-12-28 03:20:13
问题 I need to get data from the serial port of a Linux system and convert it to TCP/IP to send to a server. Is this difficult to do? I have some basic programming experience, but not much experience with Linux. Is there an open source application that do this? 回答1: You don't need to write a program to do this in Linux. Just pipe the serial port through netcat: netcat www.example.com port </dev/ttyS0 >/dev/ttyS0 Just replace the address and port information. Also, you may be using a different

Python to automatically select serial ports (for Arduino)

房东的猫 提交于 2019-12-28 02:35:28
问题 Currently the python program must know which port a device (Arduino) is on before Python can communicate the device. Problem: Whenever the device is plugged out and back in, its COM port changes, so the correct serial port must be given to Python again for it to find the device. How can Python (using pySerial ) automatically search for the correct serial port to use? Is it possible for python to correctly identify the device on a serial port as an Arduino? 回答1: Use the following code to see

Serial Comm using WriteFile/ReadFile

岁酱吖の 提交于 2019-12-27 11:44:35
问题 //#include "StdAfx.h" #include <stdio.h> #include <windows.h> #include <winbase.h> #include <iostream> #include <tchar.h> using namespace std; int main() { int com = 'COM2'; string data = "\n 010400 \n"; char output[32]; //unsigned int length = 0; DCB config = {0}; bool abContinue = true; DWORD dwBytesWritten; DWORD dwBytesRead; int isRead = false; HANDLE m_hCommPort = ::CreateFile(L"COM2", GENERIC_READ|GENERIC_WRITE,//access ( read and write) 0, //(share) 0:cannot share the COM port 0, /

Virtual Serial Port for Linux

≡放荡痞女 提交于 2019-12-27 11:07:34
问题 I need to test a serial port application on Linux, however, my test machine only has one serial port. Is there a way to add a virtual serial port to Linux and test my application by emulating a device through a shell or script? Note: I cannot remap the port, it hard coded on ttys2 and I need to test the application as it is written. 回答1: You can use a pty ("pseudo-teletype", where a serial port is a "real teletype") for this. From one end, open /dev/ptyp5 , and then attach your program to

Reading serial data in linux byte-for-byte at 56K reliably

假如想象 提交于 2019-12-26 12:23:40
问题 I'm trying to create a function with the most minimal delay possible that checks to see if the serial port has data and if it does, it reads every single byte and prints each byte in hex format until no more bytes are available. If there is no data, the function must return right away. This is my code: int fd=open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_SYNC); // Trying to set correct options here struct termios o; tcgetattr(fd,&o); cfsetispeed(&o,57600); cfsetospeed(&o,57600); /* 8 bits, no

macOS blocking serial I/O

倾然丶 夕夏残阳落幕 提交于 2019-12-25 18:37:11
问题 I'm writing a tool as part of a test suite, which needs to talk over a serial port to some hardware so that the code being tested sees the environment change. So, I do this: open("/dev/tty.usbmodem14141", O_RDWR | O_NOCTTY); only it hangs there. If I replace that call with open("/dev/tty.usbmodem14141", O_RDWR | O_NOCTTY | O_NONBLOCK); then it works -- but I would prefer not to have to fiddle with select() and friends, or write a busy-loop poll, just so I can read from the serial port; that's

My board design with a FTDI chip is a lot slower than a generic off the shelf RS232 to USB cable. Why is that the case?

别来无恙 提交于 2019-12-25 18:22:10
问题 Hello People of the internet, The company I work at implement hardware that is using RS232 however the board uses a network cable instead of a standard DB9 RS232 connector. So to remove the custom cable they need to mufacture for customers I designed a simple RS232 to USB converter that has a USB on the one side and a network cable on the other. It uses the FT230X chip from FTDI and a standard serial to rs232 converter from ST. However after doing some tests it seems that when I run my