6 ms·
From my experience as an EE, working with serial ports is much nicer on Windows (COM1, COM2, etc.) than on Linux where serial ports are abstracted to files like
by ChuckNorris89 4y ago
From my experience as an EE, working with serial ports is much nicer on Windows (COM1, COM2, etc.) than on Linux where serial ports are abstracted to files like /dev/ttyACM0 and has a lot more gotchas.
PowerShell is also quite a powerful alternative to Bash/Mingw, although it came out much later.
Windows might do some things differently than UNIX-like OSs, but it does them really well.
- klysm 4y agoI’ve found the assignment of com ports in windows really annoying
- mikub 4y agoI just started with using serial ports on windows while doing some Raspberry Pico hobby projects. Something that I find strange is that every new device gets assigned a new comport, I mean let's say I do this for a while one day I will have a comport 100, 200 and so on. Is that right, or does it somehow reset the comports?
- zwieback 4y agoThat's how it works and generally it's to the user's advantage. We often set specific parameters based on the device's serial number so getting the same COM port is nice, sometimes the devices are so simple that you cannot query its serial number. Sometimes I'll do a "blank slate" and delete all my accumulated COM ports in Device Manager (need to enable "Show Hidden Devices").
- wolletd 4y agoTechnically, COM1, COM2 etc. are filenames as well. They are just special in that they are available everywhere. That's why you are not allowed to create any file named COM1 or such. But it's a DOS relic. Actually, Windows has a "Win32 Device Namespace" under "\\.\", which is something like /dev/ in Unixoids. COM1 is actually \\.\COM1: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-device-namespaces https://learn.microsoft.com/en-us/windows/win32/fileio/namin...
- riffic 4y agoit's a CP/M relic of i'm not mistaken https://en.wikipedia.org/wiki/CP/M https://en.wikipedia.org/wiki/CP/M
- blooalien 4y agoWow! There's an operating system I ain't heard tell of in a good long while. That's the very first OS I used in a professional context. Got me my first computer store job (in my late "teens") on a CP/M system.
- pixl97 4y agoI deal with software that processes files on a Windows system... loves to break when people on other OS's subnet AUX, PRN, COM, File:Name, and tons of other unacceptable names (like 'file '). I'm glad our new releases work on Linux and we don't have to deal with that crap in 99.99% of cases now.
- throwaway09223 4y agoI've done quite a bit of work with serial ports on Windows, Linux and other unixes. I've also written a serial device driver. Your comment is very confusing to me. The serial ports are abstracted to a file on Windows just like on unixes - the file is actually discussed in the above article: \COM1 Maybe you're talking about the old days where you would just outb 0x3f8? The modern interfaces are actually fairly similar.
- zwieback 4y ago0x3f8 IRQ4, 0x2f8 IRQ3 - still hardcoded in my brain 30yrs on!
- blooalien 4y agoMy "burned in" code snippet is "call -151" from Apple ][+ days, to drop to the built-in 6502 (dis)assembler/debugger.
- zwieback 4y agoMONZ I spent a lot of time reading the disassmbly listing in the back of the manual to see what happens when I jump to the monitor.
- blooalien 4y agoRemember typing in entire programs from magazines and computer manuals and saving them to cassette tape or floppy disc? That was "the good ol' days" for sure… :)
- kevin_thibedeau 4y agoThere is also the persistent problem of USB serial adapters being assigned incremental numbers until they're in double digits that many tools don't let you select from their GUI. So you have to go in and manually purge those devices to get back to sane numbering.
- scoutt 4y agoCOM1 = CreateFile("COM1", ...) => Nice! COM9 = CreateFile("COM9", ...) => Nice! COM10 = CreateFile("\\\\.\\COM10", ...) => NOT nice!
- Kwpolska 4y agoHow often do you end up with 10 COM ports?
- zwieback 4y agoWe do all the time. In industrial automation COM ports are still shockingly popular, although it's usually the USB emulated variety. On a lot of our development and on some of our production tools we end up with COM20 or COM30, not because we have that many running at one time but because over time we've plugged in that many distinct devices. Nowadays most drivers will assign COM(n+1) when they see a device with a new serial number.
- connicpu 4y agoUART is available on nearly every microcontroller under the sun, and USB<->UART serial chips are super cheap, so it makes complete sense to me that'd become the defacto system for interfacing the automation controller with a computer
- InitialLastName 4y agoEven beyond that, USB is available on many microcontrollers, a USB CDC device is dead simple to implement, the drivers are baked into every modern OS, and all the software developers operating at that layer already know how to interact with text streams. Add in the ease of debugging when you can just manually send/receive ASCII to operate a device, and you've got the makings of a standard practice.
- rogerbinns 4y agoIf you use USB dongles for serial adapters, then each path through USB is assigned a different COM number when you plug it in. For example if you plug into USB controller 2, port 3 which goes to a hub, and then you plug into port 2 that gets a number. Now plug the same thing into a different port and it will get another COM number. Under the hood this is because the USB devices do not have the (optional) unique serial number (or in some cases they all get the same serial number). https://devblogs.microsoft.com/oldnewthing/20041110-00/?p=37343 https://devblogs.microsoft.com/oldnewthing/20041110-00/?p=37...
- JohnFen 4y agoInteresting. I very much prefer working with serial ports under Linux than Windows. It's more straightforward and easier to engage in fine control.
- BrandoElFollito 4y agoSo do I, I find the addressing more consistent, too. It used to be completely predictable when I was working with drivers on 1994 (patching the code), then less predictable when hardware for more diverse, and predictable again (or at least "always the same") with UUIDs. It was always amateur/hobby dev or sysadmin so I may have had the wrong impression.
- qalmakka 4y agoCOM ports on Windows are crap nowadays due to how crappy USB to serial adapters have become. I've seen Windows reassigning different COM names to the same device every single time it was unplugged due to it "remembering" what COM port was used previously. Needless to say, that was an anti-feature if there ever was one.
- dfox 4y agoWindows tries to keep a long term identity of all of the device instances that it knows about (and in the idela world assign the same COM port numer to the same physical serial adapter). For USB this is supposed to be done by combination of VID, PID and serial number in device descriptor. But even early on there was a lot devices that had the serial number empty and thus Windows came up with some heuristics about when this method is unreliable and switches to identifying the device by its physical position on the USB bus. The whole mechanism is well intentioned, but in the end probably somewhat misguided because it is not exactly reliable and has surprising consequences even if it were reliable. As a side note: on modern Windows NT implementations the so called "registry bloat" is non-issue (anyone who tells your otherwise is trying to sell you something), but keeping list of every device that was ever plugged into the computer in there is somewhat ridiculous.
- mmis1000 4y agoIt also do this for monitor or usb/bluetooth earphones. So you end up get earphone(2), monitor(2) even you never have a second one. The only way to fix it is delete the hidden device in device monitor and rename it back in monitor/audio manager. It's really a confusing thing to me that the script I use to change sound output and leveling suddenly didn't work after a bios/mobo software/whatever windows update and noticing the device have an appended (2).
- yndoendo 4y agoAnd this is why I hate Windows in an industry automation environment. Dislike having to troubleshoot why that USB NIC or Serial device being destroyed by plugging it into another port. Had to write a PowerShell script for the USB NIC issue to reapply NIC settings with a reboot. Also, always locking an open file is repulsive. Other OSs allow for renaming an open file. Not Windows! Thumbs.db being locked because File Explorer keeps the file open / locked preventing deleting an empty folder and wastes so much time waiting for Windows to unlock the file. You have to pay me to use Windows!