Commit 722fbdfc by EduardoChamorro

mods/html5 fabmodules tutorial fix

parent 093f6958
Pipeline #63628 passed with stage
in 5 minutes 28 seconds
......@@ -19,7 +19,7 @@
----
* Week 2: Computer Aided Design
* [Fab Modules (HTML5) setup_linux](week02_computer_aided_design/fabmodules_html5_linux.md)
* [MODS setup_linux](week02_computer_aided_design/fabmodules_html5_linux.md)
* [2D Modeling Tools and Video Tutorials](week02_computer_aided_design/2d_tools.md)
* [3D Modeling Tools and Video Tutorials](week02_computer_aided_design/3d_cad_tools.md)
* [Unwrap with Blender](week02_computer_aided_design/unwrap_blender.md)
......@@ -41,6 +41,7 @@
* Week 4: Electronics Production
* [MODS](week04_electronic_production/mods.md)
* [MODS setup_linux](week02_computer_aided_design/fabmodules_html5_linux.md)
* [FabTinyISP_english](week04_electronic_production/fabtinyisp_english.md)
* [Fab ISP_english](week04_electronic_production/fabisp.md)
* [Use an Arduino UNO as an ISP to program your first FabISP](week04_electronic_production/arduino_isp.md)
......
# HTML5 FabModules setup tutorial
# HTML5 MODS setup tutorial
### This short tutorial shows how to setup the new HTML5-based version of Fab Modules
### This short tutorial shows how to setup the new HTML5-based version of MODS
## Find the modules
**Summary**
- editing
- subgraph copy paste
- nested module graphs
- ui
- collapse nodes
- refactor for skinning
- processes
- three-axis rough and finish cuts
- Cross-Origin Resource Sharing (CORS)
- formats
- HPGL input
- SVG export
- DXF export
- ...
You can find the new modules at the following address
# To install and run mods locally
[http://mod.cba.mit.edu/mods.html](http://mod.cba.mit.edu/mods.html)
You need to first install [node.js](https://docs.npmjs.com/getting-started/installing-node).
## Pre-requisites
Install the [http-server](https://www.npmjs.com/package/http-server) npm package. Including '-g' sets the installs the package gloabally, allowing you to use it as a command line tool:
There are some pre-requisites
<code>npm install http-server -g</code>
* wget (apt-get install wget on a debian / ubuntu system)
Clone the mods repository:
* node.js & npm (download from [nodejs.org](http://nodejs.org) and follow instructions there)
<code>git clone ssh://git@gitlab.cba.mit.edu:846/pub/mods.git</code>
* Python
Use the command line to navigate to the root of the mods repository:
* PySerial library. After getting python working, just run
<code>cd mods</code>
sudo pip install pyserial
Start up a server:
## Download instructions
<code>http-server</code>
Open a terminal and create a folder where you like the fabmodules to be downloaded.
Open a browser tab and go to <code>127.0.0.1:8080</code> which is the same as <code>http://localhost:8080</code> to view the server that you just started.
In my case its /opt/fabmodules, and I'm creating it with sudo and I'm changing the ownership for this folder to my user :
Depending on how to need to use mods you can start local servers located in <code>mods/js</code>, for example, if you start from the root of the mods repository:
sudo mkdir /opt/fabmodules
sudo chown -R fiore /opt/fabmodules
<code>cd js</code>
At this point make sure you have wget installed. Start downloading the first file:
<code>node printserver.js</code>
cd /opt/fabmodules
wget http://mod.cba.mit.edu/mod_get
# Mods Connection Debugging
Now make it executable and run it:
set correct serial port permission (do this each time you reboot the machine): <code>chmod a+rwx /dev/ttyUSB0</code>
chmod +x mod_get
./mod_get
start serialserver in the terminal so you can see the logs as it tries to connect. navigate to the mods/js folder in the terminal (probably use <code>cd ~/mods/js</code>) and type: <code>node serialserver.js ::ffff:127.0.0.1 1234</code>
If you followed all the instructions correctly you should now have inside /opt/fabmodules a folder named **mod.cba.mit.edu**.
check serialserver is running with: <code>ps aux | grep node</code>
cd mod.cba.mit.edu
# Common Issues
You now need to copy it alogn with the mod_server folder to /usr/local/bin, make sure you use sudo if you don't have enough privileges. Also you need to make the mod_serve file executable:
1. **_Help! My SRM-20 will only run a single job and then go dead!_** Chances are you are using printserver.js instead of deviceserver.js to connect to the machine. For now, we need to treat the SRM-20 as a device instead of a printer.
2. **_Argg... why do I need to reset permissions on /dev/usb/lp0 every restart?_** You can use `sudo add_user username lp` and `sudo add_user username lpadmin` to make persistent permissions.
3. **_Why is my web socket connection refused when the addresses are the same?_** This can happen due to a difference between IPV4 and IPV6 addresses. In your start mods server script, try changing 127.0.0.1 to ::ffff:127.0.0.1 and see if it helps.
sudo cp -R mod_serve mod_server /usr/local/bin
sudo chmod +x /usr/local/bin/mod_serve
We are almost done.
## Start Fab Modules
You now can run the mod_serve, check /usr/local/bin is in your path:
**Forked tutorial:**
mod_serve &
listening for connections from 127.0.0.1 on 12345
You can install mod_serve on all machines where you have machines attached. Then from the Fab Modules interface type in your server/port combination instead of 127.0.0.1:12345.
You can change the host and port inside the mod_server.js file, look at the top the two lines:
var server_port = '12345'
var client_address = '127.0.0.1'
Changing client_address to 0.0.0.0 will make the server listen for connections coming from any machine in the local network (or the whole internet if the machine has a public ip-address, not recommended).
You can also change the port to any greater than 1024 (otherwise you must launch mod_serve with sudo, again not recommended).
### Starting mod_serve every time the machine is switched on
As you might notice you must launch the mod_serve manually every time you want to use Fab Modules.
You can automate this process, assuming you are running a Linux system supporting "Upstart" by creating a service entry for it.
Add a user to the system. I.e. fabmodules
sudo adduser fabmodules
Create (with sudo/root) a new file named /etc/init/fabmodules.conf, and add inside it
# upstart service file at /etc/init/fabmodules.conf
description "HTML5 Fab Modules"
author "http://mod.cba.mit.edu"
# When to start the service
start on runlevel [2345]
# When to stop the service
stop on shutdown
# Automatically restart process if crashed
respawn
respawn limit 10 5
# drop root proviliges and switch to mymetorapp user
setuid fabmodules
setgid fabmodules
script
export PATH=/usr/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
# set to home directory of the user Meteor will be running as
export PWD=/home/fabmodules
export HOME=/home/fabmodules
exec /usr/local/bin/mod_serve >> /home/fabmodules/fabmodules.log
end script
You can test / start your service with
sudo service fabmodules start
Stop your service with
sudo service fabmodules stop
If you find any issue go and look into the /home/fabmodules/fabmodules.log file. Be aware the log might grow big in time. So you might replace the >> with single >, to replace the whole file at each startup rather than appending to it.
## Using Fab Modules
You can use the new Fab Modules in different ways:
### Locally from your computer
Just open the index.html in your browser, and you should be going.
### Locally from a web server
You can run your own webserver on the local folder. Assuming you have Python installed just run inside the folder:
python -m SimpleHTTPServer
The open the page http://localhost:8000
### Using the CBA server
Open your browser on the http://mod.cba.mit.edu page and use the hosted version of the modules.
## Optional configuration
The file mod_settings contains the ports and speeds used for the modules operation. Make sure they match your actual devices.
You can load your mod_settings using the last menu item appearing when you open the index.html page.
* * *
**Original tutorial by:**
* Fiore Basile - [fiore.basile@gmail.com](mailto:fiore.basile@gmail.com) - Last updated 2015-01-26
* MODS CBA GITLAB - [ORIGINAL REPOSITORY](https://gitlab.cba.mit.edu/pub/mods) - Last updated 2019-02-12
......@@ -7,12 +7,12 @@
**Summary:**
* [Fab ISP "NEIL"](http://academy.cba.mit.edu/classes/electronics_production/index.html)
* [Fab ISP "NEIL" ATtiny44 - Crystal or Resonator](http://academy.cba.mit.edu/classes/electronics_production/index.html)
Parts Layout (20MHz crystal)
![image](fabisp_models/fabispcrystal.svg)
* [Fab ISP "ALI"](http://fab.cba.mit.edu/classes/863.16/doc/tutorials/FabISP/FabISP_Demystified.html)
* [Fab ISP "ALI" FabOptimus ATtiny44](http://fab.cba.mit.edu/classes/863.16/doc/tutorials/FabISP/FabISP_Demystified.html)
Parts Layout
![image](fabisp_models/faboptimus.png)
......@@ -28,7 +28,23 @@
* [Fab ISP key "VALENTIN"](http://fab.cba.mit.edu/classes/863.11/people/valentin.heun/2.htm)
* [FabISP-ATtiny44 -Big Crystal](http://fab.cba.mit.edu/content/projects/fabisp/)
* [Fab Tiny ISP- ATtiny45](http://fab.cba.mit.edu/classes/863.16/doc/projects/ftsmin/index.html)
* [TinyStar-ATtiny45](http://fabacademy.org/archives/2015/doc/projects/FabTinyStar/)
**Downloadable Electonics libraries**
* [FabIsp Firmware *ATtiny44*](files/firmware_44.zip)
* [FabIsp Firmware *ATtiny45*](files/firmware_45.zip)
* [Fab Eagle Library](files/fab.lbr)
* [Fab Eagle Design Rules](files/fabmodule.dru)
>For downloading the content,(right click - save as)
----
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment