nneves / 3dprinterinterface Goto Github PK
View Code? Open in Web Editor NEW3D Printer Interface
3D Printer Interface
It seems that my code refactoring messed up the current printing from .gcode file in the core.js module, while trying to optimize the way gcode was sent to printer it seems to send to much data and may probably overrun the printer memory.
Can not send manual gcode commands while in the middle of a block file printing - will ruin printer ack sync command - 'ok' will unlock next block instructions.
spWrite() direct Serial Port write functions is currently exported on the core.js module due to previous port from the original prototype.
All related GCODE data should use the standard readable/writable Stream interface, this means that stream from .gcode file and direct webinterface sendGCode command will only use this channel.
This applies to .gcode files that start with comments without having a specific GCODE command associated:
;TYPE:CUSTOM
M92 E865.888000
M109 S220.000000
;Basic settings: Layer height: 0.2 Walls: 0.8 Fill: 20
;Print time: 0:17
;Filament used: 0.45m 3.87g
;Filament cost: Unknown
If .gcode file contains inline comments the printer will not respond and process will not continue.
demo:
M104 S200 ; wait for temperature to be reached
G28 ; home all axes
G90 ; use absolute coordinates
G21 ; set units to millimeters
G92 E0 ; reset extrusion distance
M82 ; use absolute distances for extrusion
G1 Z0.200 F7800.000 ; move to next layer
Current functionality allows the user to request to print data from .gcode file and still send manual GCODE commands via parallel REST endpoint and by using the lower level jsonStream (exported as cmdStreamPrinter).
Parallel commands may be allowed (fetch temperature, etc) but will need some filter to avoid breaking the current printing job.
At the moment there is no way to get the printer (serial port) data response from the node.js application directly into the client (browser) due to the initial necessity to make te all process quick and asynchronous. Every client request is done via XHR and node.js will respond with an 'ACK' (updated to {"result": true} for every request, independently if printer communicaties or not! (response is related to the http request and not to async serial port communication)
It is required to pass some of the printer serial port data back to the client:
New communication channel is now set using sokcet.io, printer mapped messages are sent to client/browser after the 1st client gets connected but previous code wouldn't cache the initialization messages or other data.
Please check issue #2 for more details.
When starting to print from a .gcode file, normally the printer gets set to use absolute position for the XYZ movements (G90) but when sending manual GCODE commands from the UI/front-end WebApp it is expected to use relative movement (G91) to avoid caching of the printer XYZ coords.
Possible solution1: Start caching the printer XYZ coords or request this data before making the initial absolute movement (whenever user switches from print from .gcode file to UI printer manual control)
Possibel solution2: Printer gets initialised with G91, every time the user requests to print .gcode file, the prior UI printer manual control command requires to send a mandatory G91 code. If parallel commands are allowed when printing from .gcode file, then this will raise and additional problem of switching from relative to absolute position (don't think that manual movement gcode commands will be allowed while printing from file - may ruin the printing job)
When printing from .gcode file Serial Port response callback function gets mapped several times (one additional map for every request) and responses get replicated over the console with multiple 'ACK'.
Current WebSocket functionality (socket.io) was set in code with fixed values ([rest.js] ipaddress and tcpport), hooked to the REST API interface (harcoded values).
Create a REST node to retrieve the WS config data:
http://127.0.0.1:9080/api/getwsconfig/
{"response":{"ipaddress":"192.168.1.109","tcpport":9081,"websockets":true}}
.
Adjust UI javascript code to only use WS if the config property "websockets" is set to TRUE, if not WS should not be initialized and /public/socket.io/socket.io.js should return a blank file instead of the dynamic version provided by the socket.io node module.
Add support for the STL to GCODE conversion (linux embedded board local app - currently testing with Slic3r due to Linux ARM support)
Need to list the cache GCODE and STL files. This will be required by the UI/front-end webapp to be able to select a specific file to be converter / printed.
Current available REST endpoint only support async requests and would response with a {"response": "ok"}; message without waiting for the printer response (ack from the rest app and not from the printer), data was then fetched from socket.io channel.
Getting this a bit more cleaned, REST should have async ans sync endpoint versions, where the sync should only respond to request after the printer response has been triggered (using a callback queue for that effect).
Remove old un-finished ./config/*.json configuration files and implement a new functionality based on node-config module: https://npmjs.org/package/config
When launching webapp 'node app.js' it will run with the default.json config file.
To set an alternative just type:
$ export NODE_ENV=linux
$ node app.js
or
$ export NODE_ENV=macosx
$ node app.js
To create your own config file just clone the default.json, rename it to a specific NAME and then export that name before launching app.js.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.