{"id":311,"date":"2023-09-07T02:00:50","date_gmt":"2023-09-06T17:00:50","guid":{"rendered":"https:\/\/www.aqua-informatics.jp\/?p=311"},"modified":"2023-09-07T06:53:29","modified_gmt":"2023-09-06T21:53:29","slug":"%e6%b5%9c%e6%9d%be%e3%83%9b%e3%83%88%e3%83%8b%e3%82%af%e3%82%b9c12880ma%e3%82%92raspberry-pi-pico%e3%80%81micropython%e3%81%a7%e4%bd%bf%e3%81%864","status":"publish","type":"post","link":"https:\/\/www.aqua-informatics.jp\/?p=311","title":{"rendered":"\u6d5c\u677e\u30db\u30c8\u30cb\u30af\u30b9c12880ma\u3092Raspberry Pi Pico\u3001MicroPython\u3067\u4f7f\u3046(4)"},"content":{"rendered":"\n<p>PC\u306b\u63a5\u7d9a\u3055\u308c\u305fc12880ma\u3092\u8a8d\u8b58\u3059\u308b\u30af\u30e9\u30b9\u3092\u5c0e\u5165\u3057\u3066\u307f\u305f\u3002\u4e00\u5fdc\u3001\u52d5\u4f5c\u3092\u78ba\u8a8d\u3057\u305f\u304c\u3001\u73fe\u72b6\u3001\u305d\u306e\u78ba\u8a8d\u306fLinux\u306e\u307f\u306a\u306e\u3067\u3042\u308b\u3002<\/p>\n\n\n\n<p>\u305d\u3082\u305d\u3082\u3001Windows\u30de\u30b7\u30f3\u3092\u6301\u3063\u3066\u3044\u306a\u3044\u3002\u6b63\u78ba\u306b\u306f\u4f1a\u793e\u652f\u7d66\u306ePC\u304cWindows\u306a\u306e\u3060\u3002\u3057\u304b\u3082\u3001\u30b7\u30f3\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3060\u3057\u3001Python\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u8a31\u53ef\u3092\u3068\u3063\u3066\u3044\u306a\u3044\u3002\u4ee5\u524d\u306fAnaconda\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u8a31\u53ef\u3092\u3082\u3089\u3063\u3066\u3044\u305f\u306e\u3067\u3042\u308b\u304c\u2026<\/p>\n\n\n\n<p>\u3055\u3066\u3001\u3069\u306e\u69d8\u306b\u52d5\u4f5c\u78ba\u8a8d\u3092\u3057\u305f\u3089\u826f\u3044\u306e\u3060\u308d\u3046\u3002\u3042\u3001\u5618\u3064\u3044\u305f\u2026<br>Windows\u30de\u30b7\u30f3\u3092\u3082\u3063\u3066\u3044\u308b\u3002CNC\u7528\u3068\u30ec\u30fc\u30b6\u30fc\u30ab\u30c3\u30bf\u30fc\u7528\u306b3\u53f0\u3001Windows PC\u304c\u5b58\u5728\u3059\u308b\u306e\u3067\u3042\u308b\u3002\u3059\u3063\u304b\u308a\u5b58\u5728\u3092\u5fd8\u308c\u3066\u3044\u305f\u3002<br>\u3053\u308c\u3089\u3067\u30c6\u30b9\u30c8\u3092\u3057\u3066\u307f\u308b\u304b\u3002\u30b5\u30dd\u30fc\u30c8\u5207\u308c\u3066\u308bWindows 7\u306a\u306e\u3067\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u5207\u3063\u3066\u3044\u308b\u3002\u3061\u3087\u3063\u3068\u9762\u5012\u304f\u3055\u3044\u306a\u3002exe\u5316\u3092\u8a66\u3057\u3066\u307f\u308b\u304b\u306a\u3002<\/p>\n\n\n\n<p>\u3055\u3066\u3001\u30b7\u30ea\u30a2\u30eb\u30dd\u30fc\u30c8\u306b\u63a5\u7d9a\u3092\u8a66\u307f\u3001\u63a5\u7d9a\u3067\u304d\u305f\u3089\u6240\u5c5e\u3092\u554f\u3044\u5408\u308f\u305b\u3092\u3057\u3066\u2019Spectrometer\u2019\u304c\u5e30\u3063\u3066\u304d\u305f\u30dd\u30fc\u30c8\u3092\u4f7f\u3046\u3088\u3046\u306b\u5909\u66f4\u3057\u305f\u3002\u6b63\u78ba\u306b\u306fc12880ma\u304c\u63a5\u7d9a\u3055\u308c\u305fRaspberry Pi Pico\u3078\u306e\u554f\u3044\u5408\u308f\u305b\u3067\u3042\u308b\u3002<\/p>\n\n\n\n<p>\u5f53\u7136\u306a\u304c\u3089\u3001Raspberry Pi Pico\u5074\u306b\u306f\u4eca\u56de\u306e\u30b3\u30de\u30f3\u30c9\u306b\u5bfe\u5fdc\u3059\u308b\u56de\u7b54\u304c\u5fc5\u8981\u306a\u306e\u3067\u3042\u308b\u304c\u3001\u3053\u308c\u306b\u3064\u3044\u3066\u306f\u968f\u5206\u524d\u306b\u7528\u610f\u3057\u3066\u3044\u305f\u306e\u3067\u305d\u308c\u3092\u5229\u7528\u3057\u305f\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import platform\nimport serial.tools.list_ports\nimport time\n\nclass ident_PC():\n\n    def __init__(self):\n\n        self.OS = platform.system()\n        self.Version = platform.version()\n        self.Platform = platform.platform()\n        self.uart_message = &quot;Initialize class&quot;\n\n    def scan(self):\n\n        self.ports = serial.tools.list_ports.comports()\n        \n        for p in self.ports:\n\n                print(&quot;: %s&quot; % p)\n                print(&quot;device: %s&quot; % p.device)\n                print(&quot;name: %s&quot; % p.name)\n                print(&quot;description: %s&quot; % p.description)\n                print(&quot;hwid: %s&quot; % p.hwid)\n                print(&quot;vid: %s&quot; % p.vid)\n                print(&quot;pid: %s&quot; % p.pid)\n                print(&quot;serial Number: %s&quot; % p.serial_number)\n                print(&quot;location: %s&quot; % p.location)\n                print(&quot;manufacturer: %s&quot; % p.manufacturer)\n                print(&quot;product: %s&quot; % p.product)\n                print(&quot;interface: %s&quot; % p.interface)\n    \n    def chk_c12880ma(self):\n        \n        self.ports = serial.tools.list_ports.comports()\n        \n        for p in self.ports:\n            if p.manufacturer == &quot;MicroPython&quot;:\n                try:\n                    self.uartport = serial.Serial(\n                        port=p.device,\n                        baudrate=115200,\n                        bytesize=serial.EIGHTBITS,\n                        parity=serial.PARITY_NONE,\n                        stopbits=serial.STOPBITS_ONE,\n                        timeout=None\n                        )\n                    \n                    # buffer clear \n                    self.uartport.reset_input_buffer()\n                    self.uartport.reset_output_buffer()\n                    self.uartport.write((&quot;identify&quot; + &quot;\\n&quot;).encode(&quot;utf-8&quot;))\n                    \n                    try:\n                        data = self.uartport.readline()\n                        if data.decode(&#39;utf-8&#39;).rstrip(&#39;\\r\\n&#39;) == &#39;Spectrometer&#39;:\n                            self.uart_message = &quot;Successful connection to c12880ma on %s \\&quot;%s\\&quot;.&quot; % (self.OS, p.device)\n                            return()\n                        else:\n                            self.uartport.close()\n                    except serial.SerialException:\n                        self.uart_message = &quot;Failed to receive.&quot;\n       \n                except serial.SerialException:\n                    self.uart_message = &quot;Failed to open serial port.&quot;\n                \n        self.uart_message = &quot;not found c12880ma.&quot;\n        \nif __name__ == &#39;__main__&#39;:\n\n    pc = ident_PC()\n    pc.chk_c12880ma()\n\n    if pc.uart_message == &quot;not found c12880ma.&quot;:\n        print(pc.uart_message)\n    else:\n        print(pc.uart_message)\n        pc.uartport.close()<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>PC\u306b\u63a5\u7d9a\u3055\u308c\u305fc12880ma\u3092\u8a8d\u8b58\u3059\u308b\u30af\u30e9\u30b9\u3092\u5c0e\u5165\u3057\u3066\u307f\u305f\u3002\u4e00\u5fdc\u3001\u52d5\u4f5c\u3092\u78ba\u8a8d\u3057\u305f\u304c\u3001\u73fe\u72b6\u3001\u305d\u306e\u78ba\u8a8d\u306fLinux\u306e\u307f\u306a\u306e\u3067\u3042\u308b\u3002 \u305d\u3082\u305d\u3082\u3001Windows\u30de\u30b7\u30f3\u3092\u6301\u3063\u3066\u3044\u306a\u3044\u3002\u6b63\u78ba\u306b\u306f\u4f1a\u793e\u652f\u7d66\u306ePC\u304cWindows\u306a\u306e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":87,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","_lightning_design_setting":{"layout":"default"},"footnotes":""},"categories":[7,8,5],"tags":[],"class_list":["post-311","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-python","category-5"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=\/wp\/v2\/posts\/311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=311"}],"version-history":[{"count":7,"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=\/wp\/v2\/posts\/311\/revisions"}],"predecessor-version":[{"id":322,"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=\/wp\/v2\/posts\/311\/revisions\/322"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=\/wp\/v2\/media\/87"}],"wp:attachment":[{"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aqua-informatics.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}