J'avais fait ce code alors si ça peut aidé quelqu'un ^^ (j'avais commencer pour qu'il soit multi-OS, mais pas encore tester sur Linux) :
Code : Tout sélectionner
#SERIAL_PORTCOM_MIN = 1
#SERIAL_PORTCOM_MAX = 127
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
#PortName = "COM"
CompilerCase #PB_OS_Linux
#PortName = "/dev/ttyS"
CompilerCase #PB_OS_MacOS
#PortName = #Null$
End
CompilerEndSelect
Procedure SERIAL_FindPort()
;
;
;
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 = #PortName + Str(i)
iPortCom = OpenSerialPort(#PB_Any, sPortCom, 9600, #PB_SerialPort_NoParity, 8, 1, #PB_SerialPort_NoHandshake, 512, 512)
If 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, 512, 512)
If IsSerialPort(iPortCom)
CloseSerialPort(iPortCom)
Debug ">>>>>>>>>>>>>>> " + StringField(sPortBaud, j + 1, ";") + " Baud PASS"
EndIf
Next j
;
EndIf
Next i
EndProcedure
SERIAL_FindPort()
GallyHC