Serial port names on Mac OS X - macos

I am developing a cross-platform User Interface with Qt, and I need to communicate through a serial port.
I am able to use the serial port on Windows and Linux by using the following port names:
COM1, COM2, and so on, on Windows;
ttyACM0, ttyS0, ttyS1, etc, on Linux.
Now I want to do the same on Mac OS X. Do you know which are the possible port names on Mac OS X?
Thanks in advance!

They could be pretty much anything. They'll probably be /dev/tty.SOMETHING, but there's no guarantee of that. For example, my USB->serial dongle is: /dev/tty.usbserial-FTG6RCEJ. The last bit of gibberish there is a serial number or something, I think.
Shouldn't you be asking the user for which port to use, anyway?

To use the programmer in Mac OS X, you will need to determine which names have been assigned to its serial ports.
To do this, open a Terminal window, type ls /dev/tty.usb*, and press enter. You should see two entries of the form tty.usbmodem<number> (e.g. /dev/tty.usbmodem00022331). These entries represent virtual serial ports created by the programmer.
The entry with the lower number is your programmer’s Programming Port, and later you will need to pass its name as a parameter to AVRDUDE. The entry with the higher number (which should be two plus the lower number) is the TTL Serial Port, and you can use a terminal program such as screen to send and receive bytes from it.
If you have other USB devices plugged in, you might see additional serial ports for those devices.

Using an Arduino, one of mine is:
/dev/tty.usbmodemfa131
The last 5 characters are different for each port.

The name of the serial port in OS X is dependant on the driver. It might be something like /dev/tty.USBSERIAL/ and it might be /dev/tty.PL2303-xxx
You might wish to have the user create a symlink such as /dev/tty.MY_APP_USB that points to their specific serial port.

many USB->miniUSB cables no has all pins plugged, only Vcc and GND. Them, cables may be the problem

Related

Simulate serial port device using stdin and stdout

Currently, I have a desktop app that I used to read and write data to a proprietary hardware device via a serial port interface. The app starts by listing the serial COM devices connected to the computer, and once a device is selected, one can interact with the app to communicate with the corresponding device. I no longer have such a device at hand, but I would still like to use the app nonetheless.
I have already developed a command-line utility that, given a binary message in stdin, emits the corresponding binary reply (the same reply that the proprietary hardware device would send via serial port) to stdout. Let's call this utility a simulator.
How do I set up a virtual serial port such that the app can detect it, and that whenever the app sends a message using the serial port protocol, such message is forwarded to the simulator, and the simulator's reply is returned back to the desktop app?
I'm on Mac OS 12 with an M1 CPU. I'm also open to solutions on Windows 10 (with less priority).
I have looked at previous questions on StackOverflow that might be similar to this one, but they were either incomplete or slightly different, with no obvious way to infer the solution for my actual problem.
Serial ports are unlike other channels. That's why separate system calls exist for them.
Normally, serial ports are created by physical devices (an old-fashioned serial port or a newer USB-based one) and the associated driver. Since writing a driver is quite difficult, a pragmatic and possibly unexpected approach would be to use hardware, specifically two USB-to-serial adapters. That way, a serial port is created by the drivers of the USB-to-serial adapter.
The two USB-to-serial adapters are wired to each other (RX to TX and vice versa). The will appear as two serial ports on macOS (/dev/cu.usb...).
The legacy application then connects to one of the serial ports. And your command line utility (acting as a device emulation) connects to the other serial port. All data send by the command line utility will go to the legacy application, and vice versa.
The remaining issue is how to connect your command line utility to the serial port. If you are lucky, you can use the screen command. But more likely, you will need to modify it to read and write from the serial port (instead of stdin and stdout).

MAC Address as Serial Number in Embedded Systems

Is it safe to use the MAC address as the serial number of a microcontroller in embedded systems? Is it a security threat or can it be duplicated perhaps? (Usually through software from what I read).
MAC Addresses are generated randomly by the manufacturer but as far as I understood there is a slight chance (0.000001% perhaps) that the MAC Address will be duplicate. i.e. it is not entirely unique.

Communications between Visual C++ and Arduino:

I have a Arduino app that needs to talk to my PC across the USB (Serial) connection. I have this bit of code that I lifted from the Arduino Playground at
http://arduino.cc/playground/Interfacing/CPPWindows#VisualStudio2008
this->serialPort1->PortName = "COM5"; // Replace with your COM port!
this->serialPort1->Open();
this->serialPort1->Write( "7" ); // In the future, you'll expand on this
// to write your custom data to the board
this->serialPort1->Close();
My question is how does one determine what COM port the Arduino USB cable is attached to?
There are several ways you can approach this.
The most obvious is that you simply make your application configurable and tell it which serial port to use. The port name should never change, unless you have other processes on your machine allocating virtual COM ports such as Bluetooth drivers.
A second option is that you can do what the Arduino app does and scan the serial ports on the system looking for the hardware. Since you are using the CLR, System.IO.Ports.SerialPort.GetPortNames() will give you a list of all the serial ports on the system. (You can also get this from the registry.) Then you can enumerate through them and check the status of the pins to see which serial ports have devices attached. You should probably include in your sketch a way to query the Arduino so that you can send it a command and have it give a fixed response. This would allow you to discern your application from other serial devices such as modems.
There is a third option which would involve figuring out where the FTDI driver stores its configuration information in the system/registry and going from there. This is a bit more involved, so I can't give any information on if this approach is even viable.

Configuring 2 XBee Modules on OSX for wireless connection

I am trying find out how and with which program for OSX (10.5.8) I can configure serial ports? I am trying to establish a wireless connection between two Xbee´s (RF modules) and cannot figure out how to use ZTerm nor screen under Terminal. The setup I am using is: an Arduino+Xbeeshield+Xbee with external power supply, and an xbee on the xbee explorer connected to the Computer via USB.
I am trying to gather information on this through various forums, but most of them cover the configuration issue for PC using X-CTU (which I tried with CrossOver but it doesn´t recognize ny of my ports). According to one source, using screen under Terminal should show me all my serial ports, particularly /dev/tty.KeySerial1 - but it doesn´t show, even though I´ve plugged in both my arduino+xbee shield and the xbee on the explorer.
/dev/tty.KeySerial1 is incorrect.
First step is to get the FTDI USB driver installed if it has not yet been installed. The fastest way to determine if it is installed or not is to connect the XBee Explorer board. Then go look in /dev for a device named tty.usbserial-XXXXXXXX (Xs will be a unique hex ID). If you see multiple devices like this, then you probably have the Arduino plugged in too and you will need to disconnect it to determine what the device name is for the XBee Explorer board.
Once you know the device name, all you need to do is the command "screen /dev/tty.usbserial-XXXXXXXXX 9600". That should do it for you.
You can configure the tty device itself using stty. Be sure to redirect input from the terminal you want to configure, as stty operates on it's input. For instance, to set a serial port to 9600, no parity, 8 data bits, and 1 stop bit, aka "9600N81" in Windows parlance, try:
stty 9600 cs8 -cstopb -parenb < /dev/tty.usbserial-xxxxxxxx
Programmatically, you do this by opening the serial port and using the termios(4) ioctls on the device. See the termios(4) man page for more assistance.

Unique, persistent, network device information

I've been trying write an application which will be able to connect to a network device via rndis or over wifi and perform some simple operations.
The kicker is that I want to be able to find a device I've connected to before, through either connection method. I initially figured I'd just check for a previously seen mac address, but I discovered that the rndis mac address and the wifi mac address don't match. I'm on windows so the next thing I tried was to use nbtstat -A and ping -a, but those didn't turn up anything unique either (I figured I might get a device name, but it doesn't seem to have one).
So my question is, is there any tool (ideally available for windows), which will allow me to retrieve some sort of unique information about a network device that will allow me to find it again? I don't have a huge amount of experience in this field so I'm not sure exactly what that would be, but I hoped that there may be a way to get the mac addresses for both network adapters while only connected to one, or perhaps use a different tool to find a device name that I'd missed.
Thank you for any advice you might give, I really appreciate it. Sorry if I'm overly wordy.
EDIT: In case I've been ambiguous. I am connecting repeatedly to an external device via RNDIS or WIFI from my desktop PC. My goal is to be able to consistently recognize the network device regardless of the connection method used.
EDIT: By networked device, I mean that I have small independant devices (such as cell phones or tablets) running a unix os, which I access from my Windows desktop via wifi or rndis, and that I would like to be able to consistently identify. So for example I might want to use this tool to connect to one of two cell phones and be able to recognize which one it is so I can recall previous operations performed with that device. So what I'm looking for is a unique (or semi unique) attribute of the cellphone available to me that is consistent when accessed via rndis or wifi.
You can get MAC address (and bunch of other network interface info) with built-in ipconfig command and parse its output later:
ipconfig /all
Alternatively, if MAC address is all you need, try getmac.

Resources