c++ - Logic to recognize the name of the COM port to which a USB to RS422 connector is connected (for Windows application)) -
i have application writing data serial port via usb rs422 convertor. convertor cable connected pc through usb hub. problem facing each time change pc in running application, name of com port changes. have change in code , recompile code run application. @ present following code using initialize serial port:
if ((comport = createfile("\\\\.\\com7", generic_write, 0, null,open_existing,file_attribute_normal,null)) == invalid_handle_value) { return false; }
here exclusively mentioning name of com port. know if there api know status of com ports , on fly recognize com port convertor connected ?
what proper way detect available serial ports on windows? question might out, @ least bit. it's not possible api, second answer implies. serial ports aren't plug & play.
so it's possible list ports. possible way think of, polling each device in list. , wait till response expecting. it's not nice.
edit: might possible friendly name, if want. how friendly name of com port in windows?
Comments
Post a Comment