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
Related
I'm coding C/C++ on an Arduino to communicate with a Node.js server over the serial port using the serialport Node.js package. I have written this code on a Mac. In my Node.js code I need to reference the USB port, for reference mine is:
/dev/tty.wchusbserialfa14
On a Mac, to get a list of ports in a format that will work in my Node.js code I use the terminal and this command:
ls /dev/{tty,cu}.*
I can not find the equivalent for a Windows computer. Could someone please tell me what the command is to list the ports on a Windows machine, in a format that I can use in my Node.js.
Thanks!
Edit: Added more context about use of ports
You are searching not USB ports, but serial ports. Because you are using USB to serial converter that build in Arduino, and looking about serial ports. How to get list of serial ports in windows you can find here or in google.
Excuse me, can't comment yet.
Thanks for your help! The following command gave me a list of ports in a format that will work in my Node.js code:
chgport
I'm using IoT-Edge on my Raspberry Pi 3. Since IoT-edge isn't compatible with Windows 10 IoT Core on Raspberry Pi 3, my Raspberry is on Raspbian.
I'm trying to read my UART ports to read XBee sensor data.
My edge's modules are written in C# thus far.
I'm using Raspbian so I can't use the class System.IO.Ports.SerialPort since System.IO.Ports is only compatible on Windows system. Is there another way to read my UART ports inside my module? (I'm ready to write a module in something other than C# if I can deploy it the same way.)
If not, is there at least a way to read/write data from a shared file between containers/raspberry without manually changing docker container file binding mode each time we deploy a module version (since the default binding mode for docker container is read-only, but my Raspberry will have to send data to sensor too)?
You are right about .NET Core not supporting serial on Linux. The latest version of the Python SDK is ready to write Edge modules. We are working on a sample and development guidance on using it, but that's not out yet. Once we have the sample/guidance out (hopefully soon), you should be able to write your module in python and read/write from the serial port. I've confirmed that it works in an Edge container.
You can use .Net Core to read UART ports. .NET Core is a cross-platform, it supports Raspbian,and applications can be written in C#.You can refer to this topic about how to use System.IO.Ports.SerialPort in .Net Core.
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?
I'm developing a project that has a number of hardware sensors connecting to the deployment machine through RS232 serial ports.
But ... I'm developing on a machine without an physical RS232 serial ports, but I would like to make fake serial ports that I can connect to and output data from with the aim of faking input from hardware sensors.
Does anyone know of a way to create a fake serial port and control it on Windows XP?
If you are developing for Windows, the com0com project might be, what you are looking for.
It provides pairs of virtual COM ports that are linked via a nullmodem connetion. You can then use your favorite terminal application or whatever you like to send data to one COM port and recieve from the other one.
EDIT:
As Thomas pointed out the project lacks of a signed driver, which is especially problematic on certain Windows version (e.g. Windows 7 x64).
There are a couple of unofficial com0com versions around that do contain a signed driver. One recent verion (3.0.0.0) can be downloaded e.g. from here.
I know this is an old post, but in case someone else happens upon this question, one good option is Virtual Serial Port Emulator (VSPE) from Eterlogic
It provides an API for creating kernel mode virtual comport devices, i.e. connectors, mappers, splitters etc.
However, some of the advertised capabilities were really not capabilities at all.
EDIT
A much better choice, Eltima. This product is fully baked. Good developer tech support. The product did all it claimed to do. Product options include both desktop applications, as well as software development kits with APIs.
Neither of these products are open source, or free. However, as other posts here have pointed out, there are other options. Here is a list of various serial utilities:
com0com (current)
com0com - With Signed Driver (old version)
Yet another place for com0com with Signed Driver (Pete's Blog)
Tactical Software
Termite
COM Port Serial Emulator
Kermit (obsolete, but still downloadable)
HWVSP3
HHD Software (free edition)
I use com0com - With Signed Driver, on windows 7 x64 to emulate COM3 AND COM4 as a pair.
Then i use COM Dataport Emulator to recieve from COM4.
Then i open COM3 with the app im developping (c#) and send data to COM3.
The data sent thru COM3 is received by COM4 and shown by 'COM Dataport Emulator' who can also send back a response (not automated).
So with this 2 great programs i managed to emulate Serial RS-232 comunication.
Hope it helps.
Both programs are free!!!!!
There's always the hardware route. Purchase two USB to serial converters, and connect them via a NULL modem.
Pro tips:
1) Windows may assign new COM ports to the adapters after every device sleep or reboot.
2) The market leaders in chips for USB to serial are Prolific and FTDI. Both companies are battling knockoffs, and may be blocked in future official Windows drivers. The Linux drivers however work fine with the clones.
Another alternative, even though the OP did not ask for it:
There exist usb-to-serial adapters.
Depending on the type of adapter, you may also need a nullmodem cable, too.
They are extremely easy to use under linux, work under windows, too, if you have got working drivers installed.
That way you can work directly with the sensors, and you do not have to try and emulate data.
That way you are maybe even save from building an anemic system.
(Due to your emulated data inputs not covering all cases, leading you to a brittle system.)
Its often better to work with the real stuff.
i used eltima make virtual serial port for my modbus application debug work. it is really very good application at development stage to check serial port program without connecting hardware.