N1DVJ
Member
Posts: 532
|
 |
« on: September 28, 2013, 10:30:50 AM » |
|
It seems that for years I've been running into software that may or may not be decent, it may or may not be the next best thing, but it won't work. There's a lot of HAM software out that STILL doesn't work generically with all the com ports available on a PC.
But that's not totally the HAM writers fault. The original PC com port scheme was so brain dead developers had to write their own code to get around it and make it work. In my opinion the only thing worse than the built in com routines were the built in video routines. And when the HD came along, it wasn't far behind.
However, the system developers eventually cleaned up their act. Eventually. But I STILL run into software that just doesn't work. I've found software that won't work except on COM1 or COM2. Then software that won't work past COM9.
The justification with some developers is that writing com routines for Windows for high numbered com channels is tedious.
Sorry, I don't buy that. You can write the SAME software for ANY com port if you do it right, and the only difference is how you init the port.
So, here's what I did in one of my Delphi programs, and this works for com ports up to COM99
ComParams := Concat('COM', IntToStr(portnum), ':',IntToStr(baudrate),',n,8,1') ; pComParams := StrPCopy(buff, ComParams); { creat null term strings } if portnum < 10 then pPortName := StrPLCopy ( buf4, ComParams, 4 ) else pPortName := StrPLCopy ( buf4, '\\.\'+ComParams, 9 );
The first part, for a single digit com number up to 9, builds a string that starts with COMx where x is the number. When the com port hits 10, the string now starts with COMxx, or 1 digit longer. In addition, the ComParams string is preceeded by the doubleback slash a period and a single back slash. So that's 1 + 4 characters long, or the length changes from 4 to 9 in the string copy command, a difference of 5. I didn't do it here, but to go past COM99 and into the hundreds, just change the length from 9 to 10, the slash thing is the same.
In Delphi you then just call the CreateFile routine using the above pPortName as the first parameter, then use the returned handle to access the port.
I've used COM ports that are virtual on other machines up in the 200's, but you have to be careful with the delays when the com port isn't really on the host machine. I've been told from various sources that this technique work up to COM768 from one person, and to com1023 from another, but I don't personally know for sure.
This technique has worked for YEARS on multiple versions of the windows operating systems.
NO MORE EXCUSES!!
|