User Tools

Site Tools


communications

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
communications [2017/02/12 22:26]
Matthew Upp
communications [2017/11/25 11:53] (current)
Matthew Upp [Table]
Line 3: Line 3:
 ====== Communications ====== ====== Communications ======
  
 +----
  
 ===== Commands ===== ===== Commands =====
-----+
  
 ==== G-code ==== ==== G-code ====
Line 16: Line 17:
  
 ==== Extended G-code ==== ==== Extended G-code ====
-See the [[extended_g-code_table|Extended G-code Table]] for G-code that is more or less specific to the MP Select Mini & Malyan printers.+See the [[extended_g-code_table|Extended G-code Table]] for G-code that is more or less specific to the MP Select Mini & Malyan printers. ​\\
 \\ \\
  
  
-==== Command ​format ​=====+==== Command ​Format ​=====
  
 <​code>​ <​code>​
Line 38: Line 39:
  
  
-=== Available ​commands ​=== +=== Available ​Commands ​=== 
-{{tablelayout?​colwidth="​70px,​90px,​180px"&​rowsFixed=1&​rowsVisible=9&​float=left}} +{{tablelayout?​rowsFixed=1&​rowsVisible=15&​colwidth="​60px,​80px,​245px"​&​float=left}} 
-^ CMD   ​^ PARAM ^ function ^ + CMD   PARAM   function ​                         
- | X     ​| Cancel print | +|  ​P    ​| X       ​| Cancel print                       ​
-   | H     ​| Homing | +:::   | H       ​| Homing ​                            ​
-   | P     ​| Pause print | +:::   | P       ​| Pause print                        
-   | R     ​| Resume print | +:::   | R       ​| Resume print                       ​
-   | M     ​| Print cache.gc | +:::   | M       ​| Print cache.gc ​                    ​
- | T0000 | Set T0 temperature | +|  ​C    ​| T0000   ​| Set T0 temperature ​                ​
-|::: | P000 | Set hotbed temperature | +| :::   ​| P000    | Set hotbed temperature ​            ​
- e    | Return printing status | +|  e    ​| e       | Return printing status ​            ​
-|::: | M   ​| Return mac address |+| :::   ​| M       ​| Return mac address ​                ​| 
 +|  J    | X       | Moves the X-Axis ​                  | 
 +|  :::  | Y       | Moves the Y-Axis ​                  | 
 +|  :::  | Z       | Moves the Z-Axis ​                  | 
 +|  S    | I       | List files on the microSD card     | 
 +|  V    |         | Displays firmware versions on LCD  | 
 +|  W    |         | Deletes WiFi SSID and password ​    | 
 +|       ​| ​        ​| ​                                   | 
 +\\
 \\ \\
  
 +----
  
-===== Sample ​code for web interface ​=====+===== Sample ​Code for Web UI ===== 
 + 
 + 
 +==== Sample Web UI ==== 
 +Moved to it's own page. [[sample_webui|Sample Web UI]] \\ 
 +\\
  
  
Line 139: Line 154:
 1.5X Speed: {C:S15} 1.5X Speed: {C:S15}
 5X Max 5X Max
 +</​code>​
 +\\
 +
 +
 +==== Send gcode though WebSocket interface ====
 +<​code>​
 +<​script>​
 +var ws = new WebSocket('​ws://​192.168.20.164:​81'​);​
 +ws.onopen = function () {
 +  ws.send("​G28"​);​
 +}
 +</​script>​
 </​code>​ </​code>​
 \\ \\
Line 144: Line 171:
  
 ==== REST ==== ==== REST ====
 +Using AJAX and REST a single line of code g-code can be sent without a socket connection.
  
-Using AJAX and REST a single line of code g-code can be sent without socket connection+<code
 +http://​192.168.2.150/​set?​code=G28 
 +</​code>​ 
 + 
 + 
 +Send extended command though REST:
  
 <​code>​ <​code>​
-http://IP_ADDRESS/set?code=G28+http://192.168.1.155/set?cmd={P:X}
 </​code>​ </​code>​
 \\ \\
  
 +==== Web Browser Address Bar ====
 +While the MP Select Mini V1/V2 is connected to WiFi you may use the format **''​%%http://​PRINTERS_IP_ADDRESS/​set?​code=G-CODE_COMMAND%%''​** to send a single line of code g-code using a web browsers address/URL bar. See the examples in the following code block.
  
-==== Send gcode though websocket interface ====+**Format:** ''​%%http://​PRINTERS_IP_ADDRESS/​set?​code=G-CODE_COMMAND%%''​ \\
 <​code>​ <​code>​
-<​script>​ +http://​192.168.20.113/​set?​code=G1 X53 
-var ws = new WebSocket('​ws://​192.168.20.164:​81'​);​ +http://192.168.20.113/​set?​code=M563 S6 
-ws.onopen ​function () { +http://192.168.20.113/set?code=G1 X Y
-  ws.send("​G28"​);​ +
-+
-</script>+
 </​code>​ </​code>​
 +
 +When a command is sent and received successfully the browser should display `Ok`, `OK`, or `ok`. Additional g-code commands can be sent one after another using the same format. ​
 +
 \\ \\
  
 +----
 +
 +
 +===== Network interface =====
 +
 +
 +==== UDP Interface ====
 +MM32 will response UDP broadcast or unicast on port 6000. 
 +
 +Command: "​{e:​e}"​ will reply with current status; "​{e:​M}"​ will echo MAC address.
 +
 +Below is sample C# code for discovery MM32 in local network. ​
 +
 +<​code>​
 +            NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();​
 +
 +            for (int i = 0; i < interfaces.Length;​ i++)
 +            {
 +                if (interfaces[i].OperationalStatus != OperationalStatus.Up) continue;
 +                IPInterfaceProperties property = interfaces[i].GetIPProperties();​
 +                foreach (UnicastIPAddressInformation ip in property.UnicastAddresses)
 +                {
 +                    //​textBox1.Text += ip.Address + Environment.NewLine;​
 +
 +                    if (ip.Address.AddressFamily == AddressFamily.InterNetworkV6) continue;
 +                    if (ip.Address.GetAddressBytes()[0] == 255 || ip.Address.GetAddressBytes()[0] == 0) continue;
 +
 +                    UdpClient client = new UdpClient(new IPEndPoint(ip.Address,​ 0));
 +                    IPEndPoint iep = new IPEndPoint(IPAddress.Broadcast,​ 6000);
 +                    byte[] buffer = Encoding.UTF8.GetBytes("​{e:​e}"​);​
 +                    client.Send(buffer,​ buffer.Length,​ iep);
 +                    Thread.Sleep(100);​
 +                    while (client.Available != 0)
 +                    {
 +                        byte[] data = client.Receive(ref iep);
 +                        //​textBox1.Text += Encoding.UTF8.GetString(data) + Environment.NewLine;​
 +
 +                        //if (Encoding.UTF8.GetString(data).Contains("​}"​)) textBox1.Text += iep.Address;​
 +                        ​
 +                        string str = Encoding.UTF8.GetString(data);​
 +
 +                            var regex = new Regex(@"​\d+"​);​
 +                            MatchCollection mc = regex.Matches(str);​
 +
 +                            if (mc.Count == 4)
 +                            {
 +                                notifyIcon1.Text = "​Extruder:"​ + mc[0].Value + "°C Target:"​ + mc[1].Value + "​°C\nPlatform:"​ + mc[2].Value + "°C Target:"​ + mc[3].Value + "​°C";​
 +                            }
 +                            ​
 +                        toolStripComboBox1.Items.Add(iep.Address);​
 +                        toolStripComboBox1.SelectedIndex = 0;
 +
 +                        localIP = ip.Address;
 +                    }
 +
 +                    client.Close();​
 +                }
 +            }
 +</​code>​
 +\\
  
 ==== TCP Interface ==== ==== TCP Interface ====
-The printer also supports TCP interface to send G-code. Create a TCP socket on port 23 and send G-code as a string to receive response. ​+The printer also supports TCP interface ​instead of COM port to send G-code. Create a TCP socket on port 23 and send G-code as a string to receive ​response.
  
   * Send empty line included LF/CR character to flush garbage in buffer. ​   * Send empty line included LF/CR character to flush garbage in buffer. ​
Line 173: Line 268:
  
 The printer by default will accept two TCP connections. If a single connection sends a command, both connected sockets will receive same response message. ​ The printer by default will accept two TCP connections. If a single connection sends a command, both connected sockets will receive same response message. ​
-\\ 
  
 +Use a program like PuTTY or another Telnet client to connect to the MP Select Mini.
  
-==== Web UI Test Page ==== 
-Moved to it's own page. [[webui_test_page|Web UI Test Page]] 
  
-\\+----
  
  
-==== WebSocket Test Page ==== 
-Moved to it's own page. [[websocket_test_page|WebSocket Test Page]] 
  
 +===== Upload Custom Web UI =====
 +<wrap lo><​wrap hi>//​NOTE:​ You'll need to be using at least UI Controller firmware version 42 to enable this feature.//</​wrap></​wrap>​
 +  - Enter ''​%%http://​PRINTERS_IP_ADDRESS/​up%%''​ into a web browsers address bar
 +  - Upload html file using the 3rd "​Choose File" button
 +  - Click the "​Upload web" button
 +  - Enter ''​%%http://​PRINTERS_IP_ADDRESS%%''​
 +  - Custom Web UI should appear
 +
 +
 +===== Default Web UI =====
 +  - Enter ''​%%http://​PRINTERS_IP_ADDRESS/​up%%''​ into a web browsers address bar
 +  - Click the "​Upload web" button (don't bother with the "​Choose File" button
 +  - Enter ''​%%http://​PRINTERS_IP_ADDRESS%%''​
 +  - Default Web UI will appear
 +
 +
 +==== Sample Web UI ====
 +Moved to it's own page. [[sample_webui|Sample Web UI]] \\
 +
 +
 +----
 +
 +
 +==== WebSocket ====
 +The printer provides a WebSocket server for integrating control panel using a Web UI. Below is sample Javascript code to send G28 command though the WebSocket: ​
 +
 +<​code>​
 +<​script>​
 +var ws = new WebSocket('​ws://​192.168.43.50:​81'​);​
 +ws.onopen = function () {
 +  ws.send("​G28"​);​
 +}
 +</​script>​
 +</​code>​
 +
 +Using JavaScript along with the WebSocket, you can create a custom Web UI.
 +
 +
 +==== WebSocket Test Page ====
 +Moved to it's own page. [[websocket_test_page|WebSocket Test Page]] \\
 +\\
communications.1486938367.txt.gz · Last modified: 2017/02/12 22:26 by Matthew Upp