{"id":1391,"date":"2014-06-26T00:10:00","date_gmt":"2014-06-25T15:10:00","guid":{"rendered":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/?p=1391"},"modified":"2014-09-03T09:35:53","modified_gmt":"2014-09-03T00:35:53","slug":"lpc1114_applescript","status":"publish","type":"post","link":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/2014\/06\/lpc1114_applescript\/","title":{"rendered":"<!--:ja-->AppleScript\u3067lpc21isp\u3092mbed\u30e9\u30a4\u30af\u306b\u4f7f\u3046<!--:--><!--:en-->Implement Mbed-like lpc21isp with AppleScript<!--:-->"},"content":{"rendered":"<p><!--:ja--><span style=\"font-size: large;\">mbed\u30e9\u30a4\u30af\u306alpc21isp + LPC1114\u74b0\u5883\u3092AppleScript\u3067\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/span><\/p>\n<p>LPC1114\u306e\u66f8\u304d\u8fbc\u307f\u306b\u306flpc21isp\u3068\u3044\u3046\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f7f\u3046\u3068\u4fbf\u5229\u3067\u3059\u3002<\/p>\n<p>MacOSX\u306e\u4e0a\u3067\u306fApplScript\u3092\u4f7f\u3046\u3068\u3001\u30d5\u30a9\u30eb\u30c0\u306b\u30d5\u30a1\u30a4\u30eb\u3092\u5165\u308c\u305f\u6642\u70b9\u3067\u81ea\u52d5\u7684\u306b\u51e6\u7406\u3092\u884c\u3046\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002\u30d5\u30a9\u30eb\u30c0\u30a2\u30af\u30b7\u30e7\u30f3\u3068\u547c\u3070\u308c\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a9\u30eb\u30c0\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u4f7f\u3063\u3066\u3001mbed\u30aa\u30f3\u30e9\u30a4\u30f3\u30b3\u30f3\u30d1\u30a4\u30e9\u304b\u3089\u30d6\u30e9\u30a6\u30b6\u7d4c\u7531\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3068\u3001\u76f4\u3050\u306b\u66f8\u304d\u8fbc\u307f\u307e\u3067\u81ea\u52d5\u7684\u306b\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\uff08\u576a\u4e95\u3055\u3093\u306e\u8a2d\u8a08\u3057\u305f<a href=\"http:\/\/www.switch-science.com\/catalog\/1714\/\">mbed LPC1114FN28<\/a>\u30e9\u30a4\u30af\u306a\u74b0\u5883\u3092\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002\u66f8\u304d\u8fbc\u307f\u306flpc21isp\u306e\u307b\u3046\u304c\u901f\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\uff09<\/p>\n<p><!--:--><!--more--><!--:ja--><\/p>\n<h2>1. AppleScript\u30d7\u30ed\u30b0\u30e9\u30e0<\/h2>\n<p>AppleScript\u30a8\u30c7\u30a3\u30bf\u3092\u4f7f\u3063\u3066\u3001\u6b21\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092~\/Library\/Scripts\/Folder Action Scripts\/write lpc21isp.scpt\u306b\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n(*\r\n lpc21isp writer script for folder action\r\n*)\r\n\r\non adding folder items to this_folder after receiving added_items\r\n set serialport to &quot;\/dev\/cu.usbserial*&quot; -- change me\r\n set lpcbin to &quot;\/opt\/local\/bin\/lpc21isp &quot; -- change me\r\n try\r\n tell application &quot;Finder&quot;\r\n --get the name of the folder\r\n set the folder_name to POSIX path of this_folder\r\n set msg to &quot;&quot;\r\n repeat with aFile in added_items\r\n set file_name to name of aFile\r\n if file_name ends with &quot;.bin&quot; then\r\n set msg to file_name\r\n end if\r\n end repeat\r\n end tell\r\n if msg is equal to &quot;&quot; then\r\n quit me -- not a bin file\r\n end if\r\n set full_path to POSIX path of this_folder &amp; file_name\r\n set dev to do shell script &quot;ls &quot; &amp; serialport\r\n set msg to &quot;Would you like to write &quot; &amp; return &amp; full_path &amp; return &amp; &quot;to&quot; &amp; dev\r\n display dialog the msg buttons {&quot;Yes&quot;, &quot;No&quot;} default button 2 with icon caution\r\n\r\n set the user_choice to the button returned of the result\r\n\r\n if user_choice is &quot;Yes&quot; then\r\n set lpccmd to lpcbin &amp; &quot; -control -bin '&quot; &amp; full_path &amp; &quot;' &quot; &amp; dev &amp; &quot; 115200 48000&quot;\r\n --\u00a0\u00a0 \u00a0write to LPC with Terminal\r\n -- tell application &quot;Terminal&quot;\r\n -- \u00a0\u00a0 \u00a0do script lpccmd\r\n -- end tell\r\n -- write to LPC with shell\r\n do shell script lpccmd\r\n end if\r\n end try\r\nend adding folder items to\r\n<\/pre>\n<h2>2. \u30d5\u30a9\u30eb\u30c0\u30fc\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u8ffd\u52a0<\/h2>\n<p>\u30d6\u30e9\u30a6\u30b6\u30fc\u3067\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u3092\u7f6e\u304f\u8a2d\u5b9a\u3092\u3057\u3066\u3044\u308b\u30d5\u30a9\u30eb\u30c0\u306bFolder Action\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br \/>\n\u30fb\u30de\u30a6\u30b9\u53f3\u30af\u30ea\u30c3\u30af\u3000\u30fc\uff1e\u30b5\u30fc\u30d3\u30b9\u30fc\uff1e\u30d5\u30a9\u30eb\u30c0\u30a2\u30af\u30b7\u30e7\u30f3\u8a2d\u5b9a<\/p>\n<p><a href=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/06\/FA01.png\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-1400\" title=\"FA01\" src=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/06\/FA01-374x300.png\" alt=\"FA01\" width=\"374\" height=\"300\" srcset=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/06\/FA01-374x300.png 374w, http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/06\/FA01.png 680w\" sizes=\"(max-width: 374px) 100vw, 374px\" \/><\/a><br \/>\n\u30fb\u95a2\u9023\u4ed8\u3051\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u9078\u629e\u3067write lpc21isp.scpt\u3092\u9078\u629e<\/p>\n<p><a href=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/06\/FA02.png\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-1401\" title=\"FA02\" src=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/06\/FA02-340x300.png\" alt=\"FA02\" width=\"340\" height=\"300\" srcset=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/06\/FA02-340x300.png 340w, http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/06\/FA02.png 483w\" sizes=\"(max-width: 340px) 100vw, 340px\" \/><\/a><\/p>\n<p>\u30fb\u30d5\u30a9\u30eb\u30c0\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5229\u7528\u306e\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b<\/p>\n<p><a href=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/06\/FA03.png\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-1402\" title=\"FA03\" src=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/06\/FA03-377x300.png\" alt=\"FA03\" width=\"377\" height=\"300\" srcset=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/06\/FA03-377x300.png 377w, http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/06\/FA03.png 483w\" sizes=\"(max-width: 377px) 100vw, 377px\" \/><\/a><\/p>\n<h2>3. \u5229\u7528\u65b9\u6cd5<\/h2>\n<p>mbed\u30b3\u30f3\u30d1\u30a4\u30e9\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3060\u3051\u3067\u3001\u81ea\u52d5\u7684\u306b\u66f8\u304d\u8fbc\u307f\u3092\u3057\u307e\u3059\u3002<\/p>\n<p>\uff08\u4e86\uff09<!--:--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>mbed\u30e9\u30a4\u30af\u306alpc21isp + LPC1114\u74b0\u5883\u3092AppleScript\u3067\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002 LPC1114\u306e\u66f8\u304d\u8fbc\u307f\u306b\u306flpc21isp\u3068\u3044\u3046\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f7f\u3046\u3068\u4fbf\u5229\u3067\u3059\u3002 MacOSX\u306e\u4e0a\u3067\u306fApp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[19,7],"tags":[],"_links":{"self":[{"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/posts\/1391"}],"collection":[{"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/comments?post=1391"}],"version-history":[{"count":15,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/posts\/1391\/revisions"}],"predecessor-version":[{"id":1407,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/posts\/1391\/revisions\/1407"}],"wp:attachment":[{"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/media?parent=1391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/categories?post=1391"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/tags?post=1391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}