Déjà je ne sais pas si ce bout de code sera utile a beaucoup, mais je poste a tout hasard. Ce code permet de détecté les Ports Com actif sur l'ordinateur et les nombres de bauds possible par ce Port Com. Même si la bibliothèque "Serial Port" est compatible avec tout les OS, je ne garantie pas le fonctionnement autre que sur "Windows", si certains peuvent faire le test "Linux" et "MacOS", merci d'avance.
Cela donne en capture (via Debug) :
Le code-source:
Code : Tout sélectionner
#SERIAL_PORTCOM_MIN = 1
#SERIAL_PORTCOM_MAX = 256
Define.i i, j, iPortCom, iPortBaud
Define.s sPortCom, sPortBaud = "50;75;110;150;300;600;1200;1800;2400;4800;9600;19200;38400;57600;115200;128000;153600;230400;256000;460800;921600"
For i=#SERIAL_PORTCOM_MIN To #SERIAL_PORTCOM_MAX
sPortCom = "COM" + Str(i)
iPortCom = OpenSerialPort(#PB_Any, sPortCom, 9600, #PB_SerialPort_NoParity, 8, 1, #PB_SerialPort_NoHandshake, 1024, 512)
If iPortCom And IsSerialPort(iPortCom)
CloseSerialPort(iPortCom)
;
Debug sPortCom + " : PASS"
;
For j=0 To CountString(sPortBaud, ";")
iPortCom = OpenSerialPort(#PB_Any, sPortCom, Val(StringField(sPortBaud, j + 1, ";")), #PB_SerialPort_NoParity, 8, 1, #PB_SerialPort_NoHandshake, 1024, 512)
If iPortCom And IsSerialPort(iPortCom)
CloseSerialPort(iPortCom)
Debug ">>>>>>>>>>>>>>> " + StringField(sPortBaud, j + 1, ";") + " Baud PASS"
EndIf
Next j
;
EndIf
Next i
GallyHC