浜松ホトニクスc12880maをRaspberry Pi Pico、MicroPythonで使う(3)
世の中Windowsを使用している人が多いわけで、しかも、Pythonや動作に必要なライブラリをインストールしてまで使ってくれる人は稀だろうから、USBのプラグを挿し込めば動くようにしなければならないわけである。
platformと言うライブラリでOSの種類やシリアルポートをスキャンすることが出来るようである。その後、接続したPicoに合言葉を送って正しい返信が来たらO.K.
という事をしてみたいわけである。
シリアルポートのmanufacturerにMicroPythonがあるポートに対して合言葉を送って返答を待つようにすれば良さそうである。
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  | 
						import platform import serial.tools.list_ports class ident_PC():     def __init__(self):         self.OS = platform.system()         self.Version = platform.version()         self.Platform = platform.platform()     def scan(self):         self.ports = serial.tools.list_ports.comports()         for p in self.ports:                 print(": %s" % p)                 print("device: %s" % p.device)                 print("name: %s" % p.name)                 print("description: %s" % p.description)                 print("hwid: %s" % p.hwid)                 print("vid: %s" % p.vid)                 print("pid: %s" % p.pid)                 print("serial Number: %s" % p.serial_number)                 print("location: %s" % p.location)                 print("manufacturer: %s" % p.manufacturer)                 print("product: %s" % p.product)                 print("interface: %s" % p.interface)     def chk_12880ma(self):  | 
					

