{"id":1202,"date":"2018-08-13T09:34:41","date_gmt":"2018-08-13T00:34:41","guid":{"rendered":"https:\/\/www.kdel.org\/wp\/?p=1202"},"modified":"2018-08-15T21:57:38","modified_gmt":"2018-08-15T12:57:38","slug":"dummy-mpsmemo-3","status":"publish","type":"post","link":"https:\/\/www.kdel.org\/wp\/?p=1202","title":{"rendered":"Dummy MPS(MEMO 3)"},"content":{"rendered":"<p>llsf-refbox\/src\/libs\/llsf_sps \u306e\u4e2d\u8eab\u3092\u898b\u3066\u3082\uff0cmodbus \u306b\u95a2\u3059\u308b\u8a2d\u5b9a\u304c\u307b\u3068\u3093\u3069\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u2026\uff0e<br \/>\n\u95a2\u9023\u3057\u305d\u3046\u306a\u306e\u306f\uff0c\u4ee5\u4e0b\u306e4\u3064\u306e\u95a2\u6570\u306e\u307f\u2026\uff0e<\/p>\n<ul>\n<li>modbus_new_tcp<\/li>\n<li>modbus_read_registers<\/li>\n<li>modbus_read_input_registers<\/li>\n<li>modbus_write_registers<\/li>\n<\/ul>\n<p>mps.h \u306e\u4e2d\u306b\u306f\uff0c<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\/\/#define MODBUS_TCP_SLAVE 0x04<\/pre>\n<p>\u3066\u306e\u304c\u3042\u308a\u307e\u3059\u304c\uff0c<br \/>\n\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3055\u308c\u3066\u3044\u307e\u3059\uff0e<br \/>\n\u3053\u308c\u306eMASTER \u307f\u305f\u3044\u306a\u306e\u304c\u8a2d\u5b9a\u3067\u304d\u305f\u3089\u3044\u3044\u306e\u306b\u306a\u3041\uff0e<\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\uff0c\u5b9f\u6a5f\u3067\u52d5\u4f5c\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3059\uff0e<br \/>\nllsf-refbox\/cfg\/config.yaml \u306emps \u306e\u90e8\u5206\u3092\u66f8\u304d\u63db\u3048\u307e\u3059\uff0e<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n  mps:\r\n    enable: true\r\n    # type: 1(incoming station), 2(singel p&amp;p), 3(double p&amp;p), 4(delivery station)\r\n    stations:\r\n      C-BS:\r\n        active: true\r\n        type: BS\r\n        # host: !ipv4 192.168.2.27\r\n        host: !ipv4 192.168.4.163\r\n        port: !tcp-port 502\r\n<\/pre>\n<p>host \u306f\uff0c\u81ea\u5206\u306e\u74b0\u5883\u306b\u5909\u3048\u3066\u304f\u3060\u3055\u3044\uff0e<\/p>\n<p>\u53d7\u4fe1\u5074\u306f\uff0cfirewall \u306e\u89e3\u9664\u304c\u5fc5\u8981\u3067\u3059\uff0e<br \/>\nFedora \u306e\u5834\u5408\u306f\uff0c<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo firewall-cmd --add-port=502\/tcp --zone=public --permanent\r\nsudo firewall-cmd --reload\r\nsudo firewall-cmd --list-all<\/pre>\n<p>\u3067\u3059\uff0e<\/p>\n<p>\u304a\u305d\u3089\u304f\uff0cMPS \u5074\u304cMASTER \u3067\uff0cRefBox \u304cSLAVE\u3068\u3057\u3066\uff0chost \u306b\u3064\u306a\u304e\u306b\u884c\u304f\u306f\u305a\u3067\u3059\uff0e<br \/>\n\u3068\u3044\u3046\u308f\u3051\u3067\uff0cRaspberry Pi(MPS)\u5074\u3067tcpdump \u3092\u7acb\u3061\u4e0a\u3052\uff0c\u30ce\u30fc\u30c8\u30d1\u30bd\u30b3\u30f3\u4e0a\u3067RefBox \u3092\u7acb\u3061\u4e0a\u3052\u3066\u307f\u308b\u3068\u2026\uff0e<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;pi@pi3Bp1 ~]$ sudo tcpdump -vvv -i wlan0 port 502 -X -s 512 -B 512\r\ntcpdump: listening on wlan0, link-type EN10MB (Ethernet), capture size 512 bytes\r\n16:00:12.917030 IP (tos 0x10, ttl 64, id 3060, offset 0, flags &#x5B;DF], proto TCP (6), length 60)\r\n    192.168.4.156.45886 &gt; pi.mbap: Flags &#x5B;S], cksum 0x2172 (correct), seq 3277209057, win 29200, options &#x5B;mss 1460,sackOK,TS val 313680079 ecr 0,nop,wscale 7], length 0\r\n\t0x0000:  4510 003c 0bf4 4000 4006 a428 c0a8 049c  E..&lt;..@.@..(....\r\n\t0x0010:  c0a8 04a3 b33e 01f6 c356 3de1 0000 0000  .....&gt;...V=.....\r\n\t0x0020:  a002 7210 2172 0000 0204 05b4 0402 080a  ..r.!r..........\r\n\t0x0030:  12b2 60cf 0000 0000 0103 0307            ..`.........\r\n16:00:12.917269 IP (tos 0x10, ttl 64, id 26614, offset 0, flags &#x5B;DF], proto TCP (6), length 40)\r\n    pi.mbap &gt; 192.168.4.156.45886: Flags &#x5B;R.], cksum 0x6ed3 (correct), seq 0, ack 3277209058, win 0, length 0\r\n\t0x0000:  4510 0028 67f6 4000 4006 483a c0a8 04a3  E..(g.@.@.H:....\r\n\t0x0010:  c0a8 049c 01f6 b33e 0000 0000 c356 3de2  .......&gt;.....V=.\r\n\t0x0020:  5014 0000 6ed3 0000                      P...n...\r\n<\/pre>\n<p>\u3068\u3044\u3046\u308f\u3051\u3067\uff0cRefBox \u304b\u3089\uff0c\u521d\u671f\u5316\u306e\u547d\u4ee4\u304c\u98db\u3093\u3067\u3044\u308b\u611f\u3058\u3067\u3059\uff0e<\/p>\n<p>\u3088\u304f\u3088\u304f\u8003\u3048\u305f\u3089modbus \u306e\u30d1\u30b1\u30c3\u30c8\u3067\u306f\u306a\u304f\uff0cTCP \u3068\u3057\u3066\u306e\u30ad\u30e3\u30d7\u30c1\u30e3\u30fc\u3067\u3059\u306e\u3067\uff0cTCP\u306e\u30d8\u30c3\u30c0\u3082\u4ed8\u3044\u3066\u307e\u3059\u306d\uff0e<\/p>\n<p>3c \u2192 60<sub>10<\/sub> byte = Length<br \/>\nc0a8 04a3 \u2192 192.168.4.163 (Raspberry pi)\uff0c<br \/>\nc0a8 049c \u2192 192.168.4.156 (Laptop PC)\uff0c<br \/>\n01f6 \u2192 502 (port)<br \/>\n\u3053\u306e\u3042\u305f\u308a\u306f\uff0cTCP \u306e\u60c5\u5831\u3067\u3059\uff0e<\/p>\n<p>\u305f\u3060\uff0c\u3053\u306e\u307e\u307e\u3060\u3068\u521d\u671f\u5316\u306e\u30d1\u30b1\u30c3\u30c8\u3067\u6b62\u307e\u3063\u3066\u3057\u307e\u3044\u307e\u3059\uff0e<br \/>\nTCP \u3067\u3059\u306e\u3067\uff0cACK \u3092\u8fd4\u3055\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\uff0e<\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\uff0c\u30d1\u30b1\u30c3\u30c8\u53d7\u4fe1\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\uff0e<br \/>\n<a href=\"https:\/\/qiita.com\/tajima_taso\/items\/13b5662aca1f68fc6e8e\">C\u8a00\u8a9e\u3067\u5b66\u3076\u30bd\u30b1\u30c3\u30c8API\u5165\u9580 \u7b2c3\u56de \u30b5\u30fc\u30d0\/\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u7de8 #1<\/a>\u3067\u3059\uff0e<\/p>\n<p>\u53d7\u4fe1\u5f8c\uff08recv\u5f8c\uff09\u306b\uff0c\u4ee5\u4e0b\u3092\u8ffd\u8a18\uff0e<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n            for(int i = 0; i &lt; recvMsgSize; i++)\r\n                    printf(&quot;%02x:&quot;, recvBuffer&#x5B;i]);\r\n            printf(&quot;\\n&quot;);\r\n<\/pre>\n<p>\u3053\u308c\u3067\uff0cRefBox \u304b\u3089\u63a5\u7d9a\u30d1\u30b1\u30c3\u30c8\u3068\u30b7\u30b0\u30ca\u30eb\u5236\u5fa1\u30d1\u30b1\u30c3\u30c8\u304c\u98db\u3093\u3067\u304d\u307e\u3059\uff0e<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">00:01:00:00:00:09:ff:10:00:0a:00:01:02:00:01:<\/pre>\n<p>Preset Multiple Registers \u3067\u3059\uff0e<br \/>\n10\u756a\u5730\u304b\u3089\u306e1\u3064\u306e\u30ec\u30b8\u30b9\u30bf\u30fc\u306e\u5024\u3092\uff0c1\u306b\u8a2d\u5b9a\u3059\u308b\uff0e<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">f2:1e:00:00:00:06:ff:04:00:03:00:01:<\/pre>\n<p>\u6700\u521d\u306e2byte \u306f\uff0c\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u8b58\u5225\u5b50\uff0e<br \/>\n\u6b21\u306e2byte \u306f\uff0c\u30d7\u30ed\u30c8\u30b3\u30eb\u8b58\u5225\u5b50\uff080\uff09\uff0e<br \/>\n\u305d\u306e\u6b21\u306e2byte \u306f\uff0c\u30d5\u30a3\u30fc\u30eb\u30c9\u9577\uff0e\u4eca\u56de\u306f6byte\uff0e<br \/>\n\u305d\u306e\u6b21\u306e2byte \u306f\uff0c\u30e6\u30cb\u30c3\u30c8\u8b58\u5225\u5b50\uff0e0xFF\uff0e<br \/>\n\u305d\u306e\u6b21\u306e1byte \u306f\uff0c\u30d5\u30a1\u30f3\u30af\u30b7\u30e7\u30f3\u30b3\u30fc\u30c9\uff0e<br \/>\n\u4eca\u56de\u306f\uff0c04\uff0eRead Input Register\uff0e3\u756a\u5730\u304b\u30891\u3064\u306e\u30ec\u30b8\u30b9\u30bf\u30fc\u306e\u5024\u3092\u8981\u6c42\u3057\u3066\u3044\u307e\u3059\uff0e<br \/>\n\u3068\u3059\u308b\u3068\uff0c\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u5fc5\u8981\u3067\u3059\u306d\uff0e<br \/>\n\u30b7\u30b0\u30ca\u30eb\u306e\u8d64\u306e\u72b6\u614b\u3092\u8fd4\u3059\u5f62\u3067\u3059\uff0e<br \/>\n\u2192 \u6545\u969c\u691c\u77e5\u3092\u884c\u3063\u3066\u3044\u308b\u3063\u307d\u3044\u3067\u3059\uff0e<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">42:7d:00:00:00:0d:ff:10:00:03:00:03:06:00:00:00:01:00:00:<\/pre>\n<p>3\u756a\u5730\u304b\u3089\u306e3\u3064\u306e\u30ec\u30b8\u30b9\u30bf\u30fc\u306e\u5024\u3092\uff0c0,1,0\u306b\u8a2d\u5b9a\u3059\u308b\uff0e<br \/>\n\u30b7\u30b0\u30ca\u30eb\u306e\u8d64\uff0c\u9ec4\uff0c\u7dd1\u306b\u5bfe\u5fdc\uff0e<\/p>\n<p>\u3068\u3044\u3046\u308f\u3051\u3067\uff0c\u30ec\u30b8\u30b9\u30bf\u30fc\u306e\u4e2d\u8eab\u306e\u307e\u3068\u3081\u304c\u5fc5\u8981\u305d\u3046\u3067\u3059\uff0e<br \/>\n\u6b21\u306f\uff0c\u305d\u3053\u306b\u53d6\u308a\u7d44\u307f\u307e\u3059\uff0e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>llsf-refbox\/src\/libs\/llsf_sps \u306e\u4e2d\u8eab\u3092\u898b\u3066\u3082\uff0cmo &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.kdel.org\/wp\/?p=1202\"> <span class=\"screen-reader-text\">Dummy MPS(MEMO 3)<\/span> \u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[10,3,12,2,6],"tags":[],"class_list":["post-1202","post","type-post","status-publish","format-standard","hentry","category-fawkes","category-logistics-league","category-raspberry-pi","category-robocup","category-setting"],"_links":{"self":[{"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1202"}],"version-history":[{"count":9,"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1202\/revisions"}],"predecessor-version":[{"id":1216,"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1202\/revisions\/1216"}],"wp:attachment":[{"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdel.org\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}