Skip to content

Commit 80e6e01

Browse files
committed
pio and ports fixes
1 parent f835739 commit 80e6e01

File tree

9 files changed

+22
-123
lines changed

9 files changed

+22
-123
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ bower_components
3838
# Optional REPL history
3939
.node_repl_history
4040

41-
**/test
41+
**/test
42+
package-lock.json

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ some hints for [Windows-Installation](https://github.com/akaJes/marlin-config/wi
5353
* [git](https://git-scm.com/downloads)
5454
* [node.js](https://nodejs.org/en/download/)
5555
* [PlatformIO](http://docs.platformio.org/en/latest/installation.html) (optional)
56-
56+
## Hints
57+
### Linux users issue about access to USB serial ports
58+
Warning! Please install `99-platformio-udev.rules` and check that your board's PID and VID are listed in the rules.
59+
https://raw.githubusercontent.com/platformio/platformio/develop/scripts/99-platformio-udev.rules
5760
## Using
5861
open terminal in an empty folder or in a folder with Marlin repository and type
5962

app/console.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ var sio = require('socket.io');
33
var fs = require('fs');
44
var path = require('path');
55
var SerialPort = require('serialport');
6-
var linuxList = require('./linux-list');
76
var promisify = require('./helpers').promisify;
87

98
var ports={};
@@ -128,7 +127,7 @@ exports.changes=()=>new Promise((done,fail)=>{
128127
var portsList=[];
129128
exports.changesPoll=()=>{
130129
var poller=begin=>{
131-
return (process.platform=='linux'?linuxList:promisify(SerialPort.list))()
130+
return ((SerialPort.list))()
132131
.catch(a=>a)
133132
.then(ports=>{
134133
var aPorts=ports.map(p=>p.comName);

app/linux-list.js

Lines changed: 0 additions & 49 deletions
This file was deleted.

app/pio.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ exports.list=name=>new Promise((done,fail)=>{
2222
})
2323
var tty2html = require('tty2html');
2424

25-
var env = Object.create( process.env );
26-
env.PLATFORMIO_FORCE_COLOR = true;
27-
28-
var compile=(commands,res)=>{
25+
var compile=(commands, res, cwd)=>{
26+
var env = Object.assign({}, process.env, { PLATFORMIO_FORCE_COLOR: true});
2927
var verbose=0;
3028
res.writeHead(200, { "Content-Type": "text/event-stream", "Cache-control": "no-cache" });
31-
var cmd = spawn('platformio',commands, { env:env });
29+
var cmd = spawn('platformio', commands, {env: env, cwd: cwd || process.cwd() });
3230
var mw=tty2html()
3331
mw.pipe(res);
3432
cmd.stdout.pipe(mw);

app/server.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ var pioEnv = (file) =>
395395
promisify(fs.readFile)(file, 'utf8')
396396
.then(a=>a.split(/\r\n?|\n/))
397397
.then(a=>a.map(i=>i.match(/\[env\:(.*)\]/)).filter(i=>i).map(i=>i[1]))
398+
398399
app.get('/version/:screen', function (req, res) {
399400
res.set('Content-Type', 'text/plain');
400401
visitor.screenview({
@@ -419,20 +420,15 @@ function pioRoot(){
419420
return seek4File('platformio.ini', ['', 'Marlin'])
420421
}
421422
app.get('/pio/:env', function (req, res) {
422-
params=['run'];
423-
if (req.params.env!='Default')
424-
params.push('-e',req.params.env);
425-
pioRoot()
426-
.then(root=>
427-
pio.run(params,res)
428-
);
423+
var params = ['run'];
424+
if (req.params.env != 'Default')
425+
params.push('-e', req.params.env);
426+
pioRoot().then(file => pio.run(params, res, path.dirname(file)));
429427
});
430-
function atob(b64string){
428+
function atob(b64string) {
431429
if ( process.version<"v6.0.0" )
432-
// Node 5.10+
433430
return Buffer.from(b64string, 'base64');
434431
else
435-
// older Node versions
436432
return new Buffer(b64string, 'base64');
437433
}
438434

@@ -444,24 +440,17 @@ app.get('/pio/:env/:port', function (req, res) {
444440
params.push('-e',req.params.env);
445441
if (close)
446442
params.push('--upload-port',port)
447-
console.log(params); //if removed - process hangs :)
443+
console.log(); //if removed - process hangs :)
448444
(close&&serial_enabled?serial.close(port):Promise.resolve(true))
449445
.then(pioRoot)
450-
.then(root=>{
451-
var cmd=pio.run(params,res);
446+
.then(file => {
447+
var cmd = pio.run(params, res, path.dirname(file));
452448
req.on('close',function(){
453449
cmd.kill('SIGINT');
454450
console.error('flash killed')
455451
})
456452
});
457453
});
458-
app.get('/pio-flash', function (req, res) {
459-
git.root()
460-
.then(root=>{
461-
process.chdir(path.join(root,'Marlin'))
462-
pio.run(['run','-t','upload'],res);
463-
});
464-
});
465454

466455
/* SNIPPETS */
467456

builder.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "marlin-conf",
3-
"version": "2.7.12",
3+
"version": "2.7.14",
44
"description": "configuration tool for Marlin project",
55
"main": "./index.js",
66
"scripts": {

static/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ $(function(){
638638
var source = new EventSource("/ports");
639639
source.addEventListener('list', function(event) {
640640
var list= JSON.parse(event.data);
641-
$('template._ports').siblings().remove();
641+
ports.find('.dropdown-divider').nextAll().remove();
642642
list.forEach(function(p){
643643
createPort(p)
644644
});
@@ -704,7 +704,7 @@ $(function(){
704704
_add($('template._alert'))
705705
.find('p').html(`to install PlatformIO use guide from
706706
<strong><a target="_blank" href="http://docs.platformio.org/en/latest/installation.html">Official site</a></strong>
707-
<br>Linux/Mac hint: <code>sudo pip install -U platformio</code>`)
707+
<br>Linux/Mac hint: <code>sudo apt install python-pip</code> <code>sudo pip install -U platformio</code>`)
708708
}
709709
proc.log=function(text){ p.append(text); p.prop('scrollTop',p.prop('scrollHeight')); }
710710
var cmd;

0 commit comments

Comments
 (0)