I was wondering if their is an Windows equivalent of Canonical Mode Linux Serial Port.
I am developing a cross-platform serial port application that will read data line by line.
In Linux we have Canonical Mode to achieve the same. What is its (Canonical Mode's) equivalent in Windows?
I'm using Boost Asio serial port routines. I am getting the native handle and manually accessing and configuring the termios structure in Linux and COMMTIMEOUTS structure in Windows
Related
I am using Win10 and Linux Ubuntu on WSL 2.0.
For testing purposes of some programs, I would like to use the serial port of my PC in "loopback" with Linux running through WSL.
Basically I would like a process on Linux/WSL to be able to send/receive data from a Windows process or vice versa, through serial port, but without any hardware hack.
Of course I have already tried to set the Windows process serial as "COM1" (as indicated by the Windows resource manager) and the Linux port on WSL as "/dev/ttyS1", but apparently it doesn't work.
Is there any way to do this?
Status update
According to other answers, it seems that the addition of product functions has made it possible to use USB devices with WSL2.
Especially in v5.10.93.2, it seems that drivers for two types of USB serial interface chips are built in.
linux-msft-wsl-5.10.93.2
Enable CH341 and CP210X USB Serial drivers
linux-msft-wsl-5.10.60.1
Enable USB over IP support
Enable USB kernel configuration options for interacting with an Arduino over USB
The following is outdated information.
WSL 2.0 does not support serial ports.
Exceptions for using WSL 1 rather than WSL 2
WSL 2 does not include support for accessing serial ports. Learn more in the FAQs or in WSL GitHub repo issue on serial support.
The following options are possible.
Revert to WSL 1.0 and use
Use third-party products
For example, there seems to be something like this.
Windows USB Server
VirtualHere USB Server
Although it is a Japanese article, there is such a trial article.
WSL2でUSBデバイスを認識させる
Also, if you want to communicate between serial ports even if WSL2 cannot recognize USB serial, this method is also available.
Connecting to serial port (com port) over network
And as you can see from the above explanation, if you want to communicate between the processes of each OS, you can simply use a TCP/IP socket instead of the above mechanism.
Run this in PowerShell or CMD to see if you use Version 1:
C:\>wsl -l -v
NAME STATE VERSION
* Ubuntu Running 1
If yes, here's some tested working code to read COM14 from linux command prompt:
#!perl -w
use strict;
$|=1; # autoflush
use Device::SerialPort;
my $port = Device::SerialPort->new("/dev/ttyS14");
$port->baudrate(115200); # Configure below to match your device
$port->databits(8);
$port->parity("none");
$port->stopbits(0);
$port->debug(1);
$port->read_char_time(0); # don't wait for each character
$port->read_const_time(1); # 0.001 second per unfulfilled "read" call
while (1) {
my ($count_in, $str_in) = $port->read(255); # Supposedly must be 255 always
if($count_in) {
print $str_in;
}
}
If you are running WSL2, you can backup, convert or copy your distribution to WSL1 via wsl --export, wsl --import, and wsl --set-version. See this question among others for details.
Does anyone know if there is a Windows equivalent for the RDMA Communication Manager found on Linux (http://linux.die.net/man/7/rdma_cm -- librdmacm), and also ib verbs (libibverbs)?
Both these libraries are available when installing drivers for Infiniband Hardware on Linux distributions.....but what about Windows?
I've read about Windows Network Direct, but since i'm already familiar with the above mentioned Linux libs, I would like to use (if possible) their equivalents on Windows.
I have established data transfer (RDMA writes) between Linux nodes, but now I have to RDMA data from a Windows node to a Linux node, but at the moment I'm not sure which route to follow....
How do I determine whether Windows Network Direct will be compatible with IB verbs/RDMA CM?
I was under the impression that the verbs spec would be implemented on both platforms...!
Kind regards
librdmacm and libibverbs should be provided by your OpenFabrics Enterprise Distribution (OFED). There's an open source OFED for Windows provided by OFA: https://www.openfabrics.org/index.php/-download-windows-installer-.html.
I'm trying to read temperatures into NodeJS (or command-line program) app on Windows with DS18B20 thermometers connected to serial port.
There are some apps, but I can't use them (Digitemp - no support for Windows, Logtemp - it doesn't communicate with NodeJS.
Is there any possible way to read temperatures directly in NodeJS from serial port or from command-line program?
There are lots of tutorials and libraries for Arduino, but nothing for this issue.
Thanks
Can the Windows COM port be used by two programs running on the same PC for inter process communication? Our ultimate goal is to write a program which communicates over COM port to control a hardware. Since the hardware is not available we want to emulate the hardware in a program which reads from a virtual COM port and responds.
A trivial emulator would be a program which waits for bytes to be read from the COM port and responds by writing on to the COM port. To start with the values of these messages can be hardcoded.
So what I do is I have two programs written in C/C++ using the ReadFile, WriteFile functions given by windows to read and write over the file. This approach will not work because of access conflict. Hence I was wondering if our approach for the emulator itself is wrong.
I am new to Windows based programming though I have programming experience in other areas. Any help would be greatly appreciated.
Update:
Solution:
Installed Virtual Serial Port Driver 7.1 by Eltima Software (trial version)
Added a pair of virtual ports (e.g. COM1 and COM2)
The controller program communicates through COM1
The emulator program communicates through COM2
Eltima software takes care of transferring the data between the two ports
You can open a file with sharing parameters that allow both of the processes to read/write to it. But that's not a good solution, because reading/writing serial port has a number of differences with reading and writing to a file.
Instead I recommend to get a virtual COM port driver (like com0com.sourceforge.net, or select another from here en.wikipedia.org/wiki/COM_port_redirector). Install it, create two COM ports and connect them virtually. That way you will be sure that your program will work on real COM port too.
If that solution is not acceptable look into using pipes rather than a file
I've got an Atmel AVR A90USBxxxx device that I have configured to "talk USB" via CDC. It's designed to take input from a Host computer, running Windows, Linux, or OS X.
I'm under the impression that Linux and OS X will immediately recognize this CDC device, and with a simple .inf a Windows machine can be told my VID/PID should be opened as a CDC device using usbser.sys.
My question is once the OS has opened this USB device as a serial device, how can I programmatically read and write to that port (for each of the 3 OS's listed but most detail is needed for Windows as I'm completely unfamiliar there)
Thanks
The answer really depends on what programming language you intend to use. Without knowing what language you intend to use, I can't tell you exactly how to do it, but I can point you in the right direction.
For prototyping, I recommend using Python with the PySerial module. It's very easy to set up and quickly write a functional prototype. Python will run on Windows, Linux, and OS X. That way you only need to write the serial communication code once and you can test on all of your platforms.
The PySerial documentation contains some examples for how to read and write to the port.
If Python doesn't work for you in production, I would still recommend sticking with a programming language that has a cross-platform serial port library if possible.
Here's a question that was asked already about a cross-platform serial port library for C: C: cross-platform RS-232 serial library?