{"id":1067,"date":"2019-04-28T14:11:59","date_gmt":"2019-04-28T12:11:59","guid":{"rendered":"http:\/\/heppg.de\/ikg\/wordpress\/?p=1067"},"modified":"2019-04-28T14:12:53","modified_gmt":"2019-04-28T12:12:53","slug":"scratch-1-4-mesh-network-with-scratchclient","status":"publish","type":"post","link":"https:\/\/heppg.de\/ikg\/wordpress\/?p=1067","title":{"rendered":"scratch 1.4 mesh network with scratchClient"},"content":{"rendered":"\n<p>Scratch 1.4 on\nraspberry pi allows to connect with other scratch instances on other\ncomputers.<\/p>\n\n\n\n<p>This is an experimental feature. This feature is not available in scratch1.4 for linux or windows, not in scratch2.  <\/p>\n\n\n\n<p>With this feature\nmultiple scratch 1.4 can share events and (global) variables.<\/p>\n\n\n\n<p>As this feature is\nexperimental, there are some constraints and problems especially when\nscratchClient is used also.<\/p>\n\n\n\n<p>ScratchClient has a\nfeature to interconnect computers too. This uses\nscratchCommunicationServer.py which allows filtering and segmentation\nof larger networks.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Enable Mesh Session<\/h2>\n\n\n\n<p>Scratch 1.4 has a\n\u201aShare\u2018 menu point. This menu has different content when \u201ashift\u2018\nis pressed before the mouse click.<\/p>\n\n\n\n<p>Enable mesh session\nby &#8216;shift&#8217; and press &#8216;Share&#8217;-menu.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"637\" height=\"261\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/scratch_shift_share.png\" alt=\"\" class=\"wp-image-1068\" srcset=\"https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/scratch_shift_share.png 637w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/scratch_shift_share-300x123.png 300w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/scratch_shift_share-624x256.png 624w\" sizes=\"auto, (max-width: 637px) 100vw, 637px\" \/><\/figure>\n\n\n\n<p>\u201aHost Mesh\u2018\nmeans that this scratch is opening the mesh. It \u201ahosts\u2018 the mesh.\nIn other words this scratch becomes a server. \n<\/p>\n\n\n\n<p>\u201aJoin Mesh\u2018\nmeans that the scratch connects to a mesh network another computer\nhas opened before. In other words this is a \u201aclient\u2018. The client\nneeds to know the IP address of the server.<\/p>\n\n\n\n<p>When \u201aHost Mesh\u2018\nis executed, the IP address of the computer is displayed.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"991\" height=\"684\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_show_ip.png\" alt=\"\" class=\"wp-image-1069\" srcset=\"https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_show_ip.png 991w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_show_ip-300x207.png 300w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_show_ip-768x530.png 768w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_show_ip-624x431.png 624w\" sizes=\"auto, (max-width: 991px) 100vw, 991px\" \/><\/figure>\n\n\n\n<p>There is a menu\nentry on a \u201ahost\u2018 computer which allows to display this again:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"223\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_show_ip_menu.png\" alt=\"\" class=\"wp-image-1070\" srcset=\"https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_show_ip_menu.png 728w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_show_ip_menu-300x92.png 300w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_show_ip_menu-624x191.png 624w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/figure>\n\n\n\n<p>Computer A:<\/p>\n\n\n\n<p>   enable &#8216;host mesh&#8217; session<br>   display ip address, e.g. 192.168.2.200 <br><\/p>\n\n\n\n<p>Computer B:<\/p>\n\n\n\n<p>   join mesh session<br>   enter ip address of computer A <\/p>\n\n\n\n<p>Broadcast events of\none computer are sent to computer B also.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"413\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/event-1024x413.png\" alt=\"\" class=\"wp-image-1071\" srcset=\"https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/event-1024x413.png 1024w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/event-300x121.png 300w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/event-768x310.png 768w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/event-624x252.png 624w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/event.png 1791w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Global variables of\none computer are visible on &#8216;sensing&#8217; tab, sensor values on the other\ncomputer.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"500\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_variable-1024x500.png\" alt=\"\" class=\"wp-image-1072\" srcset=\"https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_variable-1024x500.png 1024w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_variable-300x146.png 300w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_variable-768x375.png 768w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_variable-624x305.png 624w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The variable (here\n\u201aa\u2018) can only be changed on the one computer where it is is\ncreated. Sensor value can\u2018t be changed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practice<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Scope: Variables should be &#8216;for this sprite only&#8217; whenever possible. Use &#8216;for all sprites&#8217; only if needed or when these should be transferred to other computer.<\/li><li>Naming: Variables and events which need to be transferred should get a special name which includes the sending computer name. So if sending computer is &#8216;box07&#8217; and variable is &#8216;a&#8217;, then name is &#8216;box07.name&#8217;.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Problems, Constraints<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Persist connection<\/h3>\n\n\n\n<p>The client side does\nnot store it&#8217;s state in the project file. &#8216;join mesh&#8217; needs to be\ndone each time the project is opened.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Topology with scratchClient<\/h3>\n\n\n\n<p>scratchClient\nconnection works on server side only. On client side, when sensor\nnetwork is enabled then the mesh connection is stopped and thus\nscratchClient can&#8217;t be used.<\/p>\n\n\n\n<p>The \u201aenable remote\nsensor connections\u2018 command is not needed when \u201aHost Mesh\u2018 is\nused. \n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"494\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_network-1024x494.png\" alt=\"\" class=\"wp-image-1073\" srcset=\"https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_network-1024x494.png 1024w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_network-300x145.png 300w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_network-768x371.png 768w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/mesh_network-624x301.png 624w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Warning<\/h3>\n\n\n\n<p>ScratchClient issues\na warning about an unknown command, but this does not stop anything.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Infrastructure<\/h2>\n\n\n\n<p>The involved\ncomputers need to be connected to a network.<\/p>\n\n\n\n<p>When computers are\nconfigured to use fixed IP-Addresses, then for a two computer network\na crossover-ethernet patch cable can be used.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"692\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/patch.png\" alt=\"\" class=\"wp-image-1074\" srcset=\"https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/patch.png 1000w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/patch-300x208.png 300w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/patch-768x531.png 768w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2019\/04\/patch-624x432.png 624w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<p>Network connection\non a raspberry pi.<\/p>\n\n\n\n<p>The color of a cable\ndoes not imply whether a normal connection or crossover connection\ntype cable is used.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Scratch 1.4 on raspberry pi allows to connect with other scratch instances on other computers. This is an experimental feature. This feature is not available in scratch1.4 for linux or windows, not in scratch2. With this feature multiple scratch 1.4 can share events and (global) variables. As this feature is experimental, there are some constraints [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,3,14],"tags":[],"class_list":["post-1067","post","type-post","status-publish","format-standard","hentry","category-scratch","category-scratchclient","category-sensor"],"_links":{"self":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1067","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1067"}],"version-history":[{"count":1,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1067\/revisions"}],"predecessor-version":[{"id":1075,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1067\/revisions\/1075"}],"wp:attachment":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1067"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1067"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1067"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}