From: Joseph Coffland Date: Fri, 16 Feb 2018 00:14:33 +0000 (-0800) Subject: - Allow RS485 to work when wires are swapped X-Git-Url: https://git.buildbotics.com/?a=commitdiff_plain;h=322251d8d503a13a9fa23cf894e480865bcf9573;p=bbctrl-firmware - Allow RS485 to work when wires are swapped - Allow setting VFD ID - Only show relavant spindle config items - More robust video camera reset - Added help page - Allow upgrade with out Internet - Limit power fault reporting - Added load over temp, load limiting and motor overload power faults --- diff --git a/CHANGELOG.md b/CHANGELOG.md index b215cbd..9d508ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,14 @@ Buildbotics CNC Controller Firmware Change Log - Added helful info to Video tab - Changed "Console" tab to "Messages" - Removed spin up/down velocity options, they don't do anything + - Allow RS485 to work when wires are swapped + - Allow setting VFD ID + - Only show relavant spindle config items + - More robust video camera reset + - Added help page + - Allow upgrade with out Internet + - Limit power fault reporting + - Added load over temp, load limiting and motor overload power faults ## v0.3.6 - Set max_usb_current=1 in /boot/config.txt from installer #103 diff --git a/Makefile b/Makefile index b10db0a..ca67c03 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,10 @@ ifndef HOST HOST=bbctrl.local endif +ifndef PASSWORD +PASSWORD=buildbotics +endif + ifndef DEST DEST=mnt endif @@ -81,7 +85,7 @@ publish: pkg update: pkg http_proxy= curl -i -X PUT -H "Content-Type: multipart/form-data" \ - -F "firmware=@dist/$(PKG_NAME).tar.bz2" \ + -F "firmware=@dist/$(PKG_NAME).tar.bz2" -F "password=$(PASSWORD)" \ http://$(HOST)/api/firmware/update mount: diff --git a/setup.py b/setup.py index fa0e3ae..561b52b 100755 --- a/setup.py +++ b/setup.py @@ -28,6 +28,7 @@ setup( 'scripts/update-bbctrl', 'scripts/upgrade-bbctrl', 'scripts/sethostname', + 'scripts/reset-video', ], install_requires = 'tornado sockjs-tornado pyserial pyudev smbus2'.split(), zip_safe = False, diff --git a/src/avr/src/huanyang.c b/src/avr/src/huanyang.c index 9cd3e0a..0bd5d35 100644 --- a/src/avr/src/huanyang.c +++ b/src/avr/src/huanyang.c @@ -491,6 +491,10 @@ void hy_rtc_callback() { sent, received, ha.response_length); } + // Try changing pin polarity + PINCTRL_PIN(RS485_RO_PIN) ^= PORT_INVEN_bm; + PINCTRL_PIN(RS485_DI_PIN) ^= PORT_INVEN_bm; + hy_reset(); } } diff --git a/src/jade/index.jade b/src/jade/index.jade index d79b422..9aa0f08 100644 --- a/src/jade/index.jade +++ b/src/jade/index.jade @@ -1,29 +1,29 @@ -//////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Buildbotics firmware. // -// // -// Copyright (c) 2015 - 2018, Buildbotics LLC // -// All rights reserved. // -// // -// This file ("the software") is free software: you can redistribute it // -// and/or modify it under the terms of the GNU General Public License, // -// version 2 as published by the Free Software Foundation. You should // -// have received a copy of the GNU General Public License, version 2 // -// along with the software. If not, see . // -// // -// The software is distributed in the hope that it will be useful, but // -// WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -// Lesser General Public License for more details. // -// // -// You should have received a copy of the GNU Lesser General Public // -// License along with the software. If not, see // -// . // -// // -// For information regarding this software email: // -// "Joseph Coffland" // -// // -//////////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////// +//- // +//- This file is part of the Buildbotics firmware. // +//- // +//- Copyright (c) 2015 - 2018, Buildbotics LLC // +//- All rights reserved. // +//- // +//- This file ("the software") is free software: you can redistribute it // +//- and/or modify it under the terms of the GNU General Public License, // +//- version 2 as published by the Free Software Foundation. You should // +//- have received a copy of the GNU General Public License, version 2 // +//- along with the software. If not, see . // +//- // +//- The software is distributed in the hope that it will be useful, but // +//- WITHOUT ANY WARRANTY; without even the implied warranty of // +//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +//- Lesser General Public License for more details. // +//- // +//- You should have received a copy of the GNU Lesser General Public // +//- License along with the software. If not, see // +//- . // +//- // +//- For information regarding this software email: // +//- "Joseph Coffland" // +//- // +//-///////////////////////////////////////////////////////////////////////////// include ../../build/hashes.jade @@ -82,6 +82,9 @@ html(lang="en") li.pure-menu-heading a.pure-menu-link(href="#admin") Admin + li.pure-menu-heading + a.pure-menu-link(href="#help") Help + #main .header .header-content @@ -138,6 +141,20 @@ html(lang="en") button.pure-button.pure-button-primary(@click="upgrade_confirmed") | Upgrade + message(:show.sync="confirmUpload") + h3(slot="header") Upload Firmware? + div(slot="body") + p Are you sure you want to upload firmware {{firmwareName}}? + + p.pure-control-group + label(for="pass") Password + input(name="pass", v-model="password", type="password") + + div(slot="footer") + button.pure-button(@click="confirmUpload=false") Cancel + button.pure-button.pure-button-primary(@click="upload_confirmed") + | Upload + message(:show.sync="firmwareUpgrading") h3(slot="header") Firmware upgrading p(slot="body") Please wait... diff --git a/src/jade/templates/admin-view.jade b/src/jade/templates/admin-view.jade index 6786923..236e7a4 100644 --- a/src/jade/templates/admin-view.jade +++ b/src/jade/templates/admin-view.jade @@ -1,29 +1,29 @@ -//////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Buildbotics firmware. // -// // -// Copyright (c) 2015 - 2018, Buildbotics LLC // -// All rights reserved. // -// // -// This file ("the software") is free software: you can redistribute it // -// and/or modify it under the terms of the GNU General Public License, // -// version 2 as published by the Free Software Foundation. You should // -// have received a copy of the GNU General Public License, version 2 // -// along with the software. If not, see . // -// // -// The software is distributed in the hope that it will be useful, but // -// WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -// Lesser General Public License for more details. // -// // -// You should have received a copy of the GNU Lesser General Public // -// License along with the software. If not, see // -// . // -// // -// For information regarding this software email: // -// "Joseph Coffland" // -// // -//////////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////// +//- // +//- This file is part of the Buildbotics firmware. // +//- // +//- Copyright (c) 2015 - 2018, Buildbotics LLC // +//- All rights reserved. // +//- // +//- This file ("the software") is free software: you can redistribute it // +//- and/or modify it under the terms of the GNU General Public License, // +//- version 2 as published by the Free Software Foundation. You should // +//- have received a copy of the GNU General Public License, version 2 // +//- along with the software. If not, see . // +//- // +//- The software is distributed in the hope that it will be useful, but // +//- WITHOUT ANY WARRANTY; without even the implied warranty of // +//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +//- Lesser General Public License for more details. // +//- // +//- You should have received a copy of the GNU Lesser General Public // +//- License along with the software. If not, see // +//- . // +//- // +//- For information regarding this software email: // +//- "Joseph Coffland" // +//- // +//-///////////////////////////////////////////////////////////////////////////// script#admin-view-template(type="text/x-template") #admin @@ -79,6 +79,9 @@ script#admin-view-template(type="text/x-template") h2 Firmware button.pure-button.pure-button-primary(@click="check") Check button.pure-button.pure-button-primary(@click="upgrade") Upgrade + label.pure-button.pure-button-primary.file-upload + input(type="file", accept=".tar.bz2", @change="upload") + | Upload p input(type="checkbox", v-model="autoCheckUpgrade", diff --git a/src/jade/templates/axis-control.jade b/src/jade/templates/axis-control.jade index a498089..83be919 100644 --- a/src/jade/templates/axis-control.jade +++ b/src/jade/templates/axis-control.jade @@ -1,29 +1,29 @@ -//////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Buildbotics firmware. // -// // -// Copyright (c) 2015 - 2018, Buildbotics LLC // -// All rights reserved. // -// // -// This file ("the software") is free software: you can redistribute it // -// and/or modify it under the terms of the GNU General Public License, // -// version 2 as published by the Free Software Foundation. You should // -// have received a copy of the GNU General Public License, version 2 // -// along with the software. If not, see . // -// // -// The software is distributed in the hope that it will be useful, but // -// WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -// Lesser General Public License for more details. // -// // -// You should have received a copy of the GNU Lesser General Public // -// License along with the software. If not, see // -// . // -// // -// For information regarding this software email: // -// "Joseph Coffland" // -// // -//////////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////// +//- // +//- This file is part of the Buildbotics firmware. // +//- // +//- Copyright (c) 2015 - 2018, Buildbotics LLC // +//- All rights reserved. // +//- // +//- This file ("the software") is free software: you can redistribute it // +//- and/or modify it under the terms of the GNU General Public License, // +//- version 2 as published by the Free Software Foundation. You should // +//- have received a copy of the GNU General Public License, version 2 // +//- along with the software. If not, see . // +//- // +//- The software is distributed in the hope that it will be useful, but // +//- WITHOUT ANY WARRANTY; without even the implied warranty of // +//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +//- Lesser General Public License for more details. // +//- // +//- You should have received a copy of the GNU Lesser General Public // +//- License along with the software. If not, see // +//- . // +//- // +//- For information regarding this software email: // +//- "Joseph Coffland" // +//- // +//-///////////////////////////////////////////////////////////////////////////// script#axis-control-template(type="text/x-template") svg(xmlns="http://www.w3.org/2000/svg", diff --git a/src/jade/templates/console.jade b/src/jade/templates/console.jade index aa0ba5e..57993fd 100644 --- a/src/jade/templates/console.jade +++ b/src/jade/templates/console.jade @@ -1,29 +1,29 @@ -//////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Buildbotics firmware. // -// // -// Copyright (c) 2015 - 2018, Buildbotics LLC // -// All rights reserved. // -// // -// This file ("the software") is free software: you can redistribute it // -// and/or modify it under the terms of the GNU General Public License, // -// version 2 as published by the Free Software Foundation. You should // -// have received a copy of the GNU General Public License, version 2 // -// along with the software. If not, see . // -// // -// The software is distributed in the hope that it will be useful, but // -// WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -// Lesser General Public License for more details. // -// // -// You should have received a copy of the GNU Lesser General Public // -// License along with the software. If not, see // -// . // -// // -// For information regarding this software email: // -// "Joseph Coffland" // -// // -//////////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////// +//- // +//- This file is part of the Buildbotics firmware. // +//- // +//- Copyright (c) 2015 - 2018, Buildbotics LLC // +//- All rights reserved. // +//- // +//- This file ("the software") is free software: you can redistribute it // +//- and/or modify it under the terms of the GNU General Public License, // +//- version 2 as published by the Free Software Foundation. You should // +//- have received a copy of the GNU General Public License, version 2 // +//- along with the software. If not, see . // +//- // +//- The software is distributed in the hope that it will be useful, but // +//- WITHOUT ANY WARRANTY; without even the implied warranty of // +//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +//- Lesser General Public License for more details. // +//- // +//- You should have received a copy of the GNU Lesser General Public // +//- License along with the software. If not, see // +//- . // +//- // +//- For information regarding this software email: // +//- "Joseph Coffland" // +//- // +//-///////////////////////////////////////////////////////////////////////////// script#console-template(type="text/x-template") .console diff --git a/src/jade/templates/control-view.jade b/src/jade/templates/control-view.jade index fdacd5c..d867a52 100644 --- a/src/jade/templates/control-view.jade +++ b/src/jade/templates/control-view.jade @@ -1,29 +1,29 @@ -//////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Buildbotics firmware. // -// // -// Copyright (c) 2015 - 2018, Buildbotics LLC // -// All rights reserved. // -// // -// This file ("the software") is free software: you can redistribute it // -// and/or modify it under the terms of the GNU General Public License, // -// version 2 as published by the Free Software Foundation. You should // -// have received a copy of the GNU General Public License, version 2 // -// along with the software. If not, see . // -// // -// The software is distributed in the hope that it will be useful, but // -// WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -// Lesser General Public License for more details. // -// // -// You should have received a copy of the GNU Lesser General Public // -// License along with the software. If not, see // -// . // -// // -// For information regarding this software email: // -// "Joseph Coffland" // -// // -//////////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////// +//- // +//- This file is part of the Buildbotics firmware. // +//- // +//- Copyright (c) 2015 - 2018, Buildbotics LLC // +//- All rights reserved. // +//- // +//- This file ("the software") is free software: you can redistribute it // +//- and/or modify it under the terms of the GNU General Public License, // +//- version 2 as published by the Free Software Foundation. You should // +//- have received a copy of the GNU General Public License, version 2 // +//- along with the software. If not, see . // +//- // +//- The software is distributed in the hope that it will be useful, but // +//- WITHOUT ANY WARRANTY; without even the implied warranty of // +//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +//- Lesser General Public License for more details. // +//- // +//- You should have received a copy of the GNU Lesser General Public // +//- License along with the software. If not, see // +//- . // +//- // +//- For information regarding this software email: // +//- "Joseph Coffland" // +//- // +//-///////////////////////////////////////////////////////////////////////////// script#control-view-template(type="text/x-template") #control @@ -275,7 +275,7 @@ script#control-view-template(type="text/x-template") section#content6.tab-content .video - img.reload(src="/images/reload.png", @click="load_video", + img.reload(src="/images/reload.png", @click="reload_video", title="Reload video") img.mjpeg(:src="video_url") diff --git a/src/jade/templates/estop.jade b/src/jade/templates/estop.jade index 748eb9e..472c72c 100644 --- a/src/jade/templates/estop.jade +++ b/src/jade/templates/estop.jade @@ -1,29 +1,29 @@ -//////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Buildbotics firmware. // -// // -// Copyright (c) 2015 - 2018, Buildbotics LLC // -// All rights reserved. // -// // -// This file ("the software") is free software: you can redistribute it // -// and/or modify it under the terms of the GNU General Public License, // -// version 2 as published by the Free Software Foundation. You should // -// have received a copy of the GNU General Public License, version 2 // -// along with the software. If not, see . // -// // -// The software is distributed in the hope that it will be useful, but // -// WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -// Lesser General Public License for more details. // -// // -// You should have received a copy of the GNU Lesser General Public // -// License along with the software. If not, see // -// . // -// // -// For information regarding this software email: // -// "Joseph Coffland" // -// // -//////////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////// +//- // +//- This file is part of the Buildbotics firmware. // +//- // +//- Copyright (c) 2015 - 2018, Buildbotics LLC // +//- All rights reserved. // +//- // +//- This file ("the software") is free software: you can redistribute it // +//- and/or modify it under the terms of the GNU General Public License, // +//- version 2 as published by the Free Software Foundation. You should // +//- have received a copy of the GNU General Public License, version 2 // +//- along with the software. If not, see . // +//- // +//- The software is distributed in the hope that it will be useful, but // +//- WITHOUT ANY WARRANTY; without even the implied warranty of // +//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +//- Lesser General Public License for more details. // +//- // +//- You should have received a copy of the GNU Lesser General Public // +//- License along with the software. If not, see // +//- . // +//- // +//- For information regarding this software email: // +//- "Joseph Coffland" // +//- // +//-///////////////////////////////////////////////////////////////////////////// script#estop-template(type="text/x-template") svg(version="1.1", xmlns:svg="http://www.w3.org/2000/svg", diff --git a/src/jade/templates/gcode-view.jade b/src/jade/templates/gcode-view.jade index e400756..edea72b 100644 --- a/src/jade/templates/gcode-view.jade +++ b/src/jade/templates/gcode-view.jade @@ -1,29 +1,29 @@ -//////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Buildbotics firmware. // -// // -// Copyright (c) 2015 - 2018, Buildbotics LLC // -// All rights reserved. // -// // -// This file ("the software") is free software: you can redistribute it // -// and/or modify it under the terms of the GNU General Public License, // -// version 2 as published by the Free Software Foundation. You should // -// have received a copy of the GNU General Public License, version 2 // -// along with the software. If not, see . // -// // -// The software is distributed in the hope that it will be useful, but // -// WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -// Lesser General Public License for more details. // -// // -// You should have received a copy of the GNU Lesser General Public // -// License along with the software. If not, see // -// . // -// // -// For information regarding this software email: // -// "Joseph Coffland" // -// // -//////////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////// +//- // +//- This file is part of the Buildbotics firmware. // +//- // +//- Copyright (c) 2015 - 2018, Buildbotics LLC // +//- All rights reserved. // +//- // +//- This file ("the software") is free software: you can redistribute it // +//- and/or modify it under the terms of the GNU General Public License, // +//- version 2 as published by the Free Software Foundation. You should // +//- have received a copy of the GNU General Public License, version 2 // +//- along with the software. If not, see . // +//- // +//- The software is distributed in the hope that it will be useful, but // +//- WITHOUT ANY WARRANTY; without even the implied warranty of // +//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +//- Lesser General Public License for more details. // +//- // +//- You should have received a copy of the GNU Lesser General Public // +//- License along with the software. If not, see // +//- . // +//- // +//- For information regarding this software email: // +//- "Joseph Coffland" // +//- // +//-///////////////////////////////////////////////////////////////////////////// script#gcode-view-template(type="text/x-template") #gcode diff --git a/src/jade/templates/help-view.jade b/src/jade/templates/help-view.jade new file mode 100644 index 0000000..76a1092 --- /dev/null +++ b/src/jade/templates/help-view.jade @@ -0,0 +1,42 @@ +//-///////////////////////////////////////////////////////////////////////////// +//- // +//- This file is part of the Buildbotics firmware. // +//- // +//- Copyright (c) 2015 - 2018, Buildbotics LLC // +//- All rights reserved. // +//- // +//- This file ("the software") is free software: you can redistribute it // +//- and/or modify it under the terms of the GNU General Public License, // +//- version 2 as published by the Free Software Foundation. You should // +//- have received a copy of the GNU General Public License, version 2 // +//- along with the software. If not, see . // +//- // +//- The software is distributed in the hope that it will be useful, but // +//- WITHOUT ANY WARRANTY; without even the implied warranty of // +//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +//- Lesser General Public License for more details. // +//- // +//- You should have received a copy of the GNU Lesser General Public // +//- License along with the software. If not, see // +//- . // +//- // +//- For information regarding this software email: // +//- "Joseph Coffland" // +//- // +//-///////////////////////////////////////////////////////////////////////////// + +script#help-view-template(type="text/x-template") + #help + h2 User Manual + p + | You can find a detailed user manual at docs.buildbotics.com. + + h2 Discussion Forum + p + | If you're having trouble or just want to chat with other Buildbotics + | CNC controller owners, head over to the Buildbotics forum at + | forum.buildbotics.com. Register on the site and post a message. + | We'll be happy to help. diff --git a/src/jade/templates/indicators.jade b/src/jade/templates/indicators.jade index 174e0ce..1231d92 100644 --- a/src/jade/templates/indicators.jade +++ b/src/jade/templates/indicators.jade @@ -1,29 +1,29 @@ -//////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Buildbotics firmware. // -// // -// Copyright (c) 2015 - 2018, Buildbotics LLC // -// All rights reserved. // -// // -// This file ("the software") is free software: you can redistribute it // -// and/or modify it under the terms of the GNU General Public License, // -// version 2 as published by the Free Software Foundation. You should // -// have received a copy of the GNU General Public License, version 2 // -// along with the software. If not, see . // -// // -// The software is distributed in the hope that it will be useful, but // -// WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -// Lesser General Public License for more details. // -// // -// You should have received a copy of the GNU Lesser General Public // -// License along with the software. If not, see // -// . // -// // -// For information regarding this software email: // -// "Joseph Coffland" // -// // -//////////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////// +//- // +//- This file is part of the Buildbotics firmware. // +//- // +//- Copyright (c) 2015 - 2018, Buildbotics LLC // +//- All rights reserved. // +//- // +//- This file ("the software") is free software: you can redistribute it // +//- and/or modify it under the terms of the GNU General Public License, // +//- version 2 as published by the Free Software Foundation. You should // +//- have received a copy of the GNU General Public License, version 2 // +//- along with the software. If not, see . // +//- // +//- The software is distributed in the hope that it will be useful, but // +//- WITHOUT ANY WARRANTY; without even the implied warranty of // +//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +//- Lesser General Public License for more details. // +//- // +//- You should have received a copy of the GNU Lesser General Public // +//- License along with the software. If not, see // +//- . // +//- // +//- For information regarding this software email: // +//- "Joseph Coffland" // +//- // +//-///////////////////////////////////////////////////////////////////////////// script#indicators-template(type="text/x-template") .indicators diff --git a/src/jade/templates/io-view.jade b/src/jade/templates/io-view.jade index 60dc9be..e433fe3 100644 --- a/src/jade/templates/io-view.jade +++ b/src/jade/templates/io-view.jade @@ -1,29 +1,29 @@ -//////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Buildbotics firmware. // -// // -// Copyright (c) 2015 - 2018, Buildbotics LLC // -// All rights reserved. // -// // -// This file ("the software") is free software: you can redistribute it // -// and/or modify it under the terms of the GNU General Public License, // -// version 2 as published by the Free Software Foundation. You should // -// have received a copy of the GNU General Public License, version 2 // -// along with the software. If not, see . // -// // -// The software is distributed in the hope that it will be useful, but // -// WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -// Lesser General Public License for more details. // -// // -// You should have received a copy of the GNU Lesser General Public // -// License along with the software. If not, see // -// . // -// // -// For information regarding this software email: // -// "Joseph Coffland" // -// // -//////////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////// +//- // +//- This file is part of the Buildbotics firmware. // +//- // +//- Copyright (c) 2015 - 2018, Buildbotics LLC // +//- All rights reserved. // +//- // +//- This file ("the software") is free software: you can redistribute it // +//- and/or modify it under the terms of the GNU General Public License, // +//- version 2 as published by the Free Software Foundation. You should // +//- have received a copy of the GNU General Public License, version 2 // +//- along with the software. If not, see . // +//- // +//- The software is distributed in the hope that it will be useful, but // +//- WITHOUT ANY WARRANTY; without even the implied warranty of // +//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +//- Lesser General Public License for more details. // +//- // +//- You should have received a copy of the GNU Lesser General Public // +//- License along with the software. If not, see // +//- . // +//- // +//- For information regarding this software email: // +//- "Joseph Coffland" // +//- // +//-///////////////////////////////////////////////////////////////////////////// script#io-view-template(type="text/x-template") #io diff --git a/src/jade/templates/message.jade b/src/jade/templates/message.jade index c4f8595..dcaf93c 100644 --- a/src/jade/templates/message.jade +++ b/src/jade/templates/message.jade @@ -1,29 +1,29 @@ -//////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Buildbotics firmware. // -// // -// Copyright (c) 2015 - 2018, Buildbotics LLC // -// All rights reserved. // -// // -// This file ("the software") is free software: you can redistribute it // -// and/or modify it under the terms of the GNU General Public License, // -// version 2 as published by the Free Software Foundation. You should // -// have received a copy of the GNU General Public License, version 2 // -// along with the software. If not, see . // -// // -// The software is distributed in the hope that it will be useful, but // -// WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -// Lesser General Public License for more details. // -// // -// You should have received a copy of the GNU Lesser General Public // -// License along with the software. If not, see // -// . // -// // -// For information regarding this software email: // -// "Joseph Coffland" // -// // -//////////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////// +//- // +//- This file is part of the Buildbotics firmware. // +//- // +//- Copyright (c) 2015 - 2018, Buildbotics LLC // +//- All rights reserved. // +//- // +//- This file ("the software") is free software: you can redistribute it // +//- and/or modify it under the terms of the GNU General Public License, // +//- version 2 as published by the Free Software Foundation. You should // +//- have received a copy of the GNU General Public License, version 2 // +//- along with the software. If not, see . // +//- // +//- The software is distributed in the hope that it will be useful, but // +//- WITHOUT ANY WARRANTY; without even the implied warranty of // +//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +//- Lesser General Public License for more details. // +//- // +//- You should have received a copy of the GNU Lesser General Public // +//- License along with the software. If not, see // +//- . // +//- // +//- For information regarding this software email: // +//- "Joseph Coffland" // +//- // +//-///////////////////////////////////////////////////////////////////////////// script#message-template(type="text/x-template") .modal-mask(v-show="show", transition="modal") diff --git a/src/jade/templates/motor-view.jade b/src/jade/templates/motor-view.jade index 0d11770..4b083fe 100644 --- a/src/jade/templates/motor-view.jade +++ b/src/jade/templates/motor-view.jade @@ -1,29 +1,29 @@ -//////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Buildbotics firmware. // -// // -// Copyright (c) 2015 - 2018, Buildbotics LLC // -// All rights reserved. // -// // -// This file ("the software") is free software: you can redistribute it // -// and/or modify it under the terms of the GNU General Public License, // -// version 2 as published by the Free Software Foundation. You should // -// have received a copy of the GNU General Public License, version 2 // -// along with the software. If not, see . // -// // -// The software is distributed in the hope that it will be useful, but // -// WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -// Lesser General Public License for more details. // -// // -// You should have received a copy of the GNU Lesser General Public // -// License along with the software. If not, see // -// . // -// // -// For information regarding this software email: // -// "Joseph Coffland" // -// // -//////////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////// +//- // +//- This file is part of the Buildbotics firmware. // +//- // +//- Copyright (c) 2015 - 2018, Buildbotics LLC // +//- All rights reserved. // +//- // +//- This file ("the software") is free software: you can redistribute it // +//- and/or modify it under the terms of the GNU General Public License, // +//- version 2 as published by the Free Software Foundation. You should // +//- have received a copy of the GNU General Public License, version 2 // +//- along with the software. If not, see . // +//- // +//- The software is distributed in the hope that it will be useful, but // +//- WITHOUT ANY WARRANTY; without even the implied warranty of // +//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +//- Lesser General Public License for more details. // +//- // +//- You should have received a copy of the GNU Lesser General Public // +//- License along with the software. If not, see // +//- . // +//- // +//- For information regarding this software email: // +//- "Joseph Coffland" // +//- // +//-///////////////////////////////////////////////////////////////////////////// script#motor-view-template(type="text/x-template") #motor diff --git a/src/jade/templates/templated-input.jade b/src/jade/templates/templated-input.jade index 1fee3d1..5ab1f72 100644 --- a/src/jade/templates/templated-input.jade +++ b/src/jade/templates/templated-input.jade @@ -1,33 +1,33 @@ -//////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Buildbotics firmware. // -// // -// Copyright (c) 2015 - 2018, Buildbotics LLC // -// All rights reserved. // -// // -// This file ("the software") is free software: you can redistribute it // -// and/or modify it under the terms of the GNU General Public License, // -// version 2 as published by the Free Software Foundation. You should // -// have received a copy of the GNU General Public License, version 2 // -// along with the software. If not, see . // -// // -// The software is distributed in the hope that it will be useful, but // -// WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -// Lesser General Public License for more details. // -// // -// You should have received a copy of the GNU Lesser General Public // -// License along with the software. If not, see // -// . // -// // -// For information regarding this software email: // -// "Joseph Coffland" // -// // -//////////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////// +//- // +//- This file is part of the Buildbotics firmware. // +//- // +//- Copyright (c) 2015 - 2018, Buildbotics LLC // +//- All rights reserved. // +//- // +//- This file ("the software") is free software: you can redistribute it // +//- and/or modify it under the terms of the GNU General Public License, // +//- version 2 as published by the Free Software Foundation. You should // +//- have received a copy of the GNU General Public License, version 2 // +//- along with the software. If not, see . // +//- // +//- The software is distributed in the hope that it will be useful, but // +//- WITHOUT ANY WARRANTY; without even the implied warranty of // +//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +//- Lesser General Public License for more details. // +//- // +//- You should have received a copy of the GNU Lesser General Public // +//- License along with the software. If not, see // +//- . // +//- // +//- For information regarding this software email: // +//- "Joseph Coffland" // +//- // +//-///////////////////////////////////////////////////////////////////////////// script#templated-input-template(type="text/x-template") .pure-control-group(class="tmpl-input-{{name}}", - title="Default {{template.default}} {{template.unit}}") + title="Default {{template.default}} {{template.unit || ''}}") label(:for="name") {{name}} select(v-if="template.type == 'enum' || template.values", v-model="model", diff --git a/src/jade/templates/tool-view.jade b/src/jade/templates/tool-view.jade index 304d21a..c28debb 100644 --- a/src/jade/templates/tool-view.jade +++ b/src/jade/templates/tool-view.jade @@ -1,35 +1,50 @@ -//////////////////////////////////////////////////////////////////////////////// -// // -// This file is part of the Buildbotics firmware. // -// // -// Copyright (c) 2015 - 2018, Buildbotics LLC // -// All rights reserved. // -// // -// This file ("the software") is free software: you can redistribute it // -// and/or modify it under the terms of the GNU General Public License, // -// version 2 as published by the Free Software Foundation. You should // -// have received a copy of the GNU General Public License, version 2 // -// along with the software. If not, see . // -// // -// The software is distributed in the hope that it will be useful, but // -// WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -// Lesser General Public License for more details. // -// // -// You should have received a copy of the GNU Lesser General Public // -// License along with the software. If not, see // -// . // -// // -// For information regarding this software email: // -// "Joseph Coffland" // -// // -//////////////////////////////////////////////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////// +//- // +//- This file is part of the Buildbotics firmware. // +//- // +//- Copyright (c) 2015 - 2018, Buildbotics LLC // +//- All rights reserved. // +//- // +//- This file ("the software") is free software: you can redistribute it // +//- and/or modify it under the terms of the GNU General Public License, // +//- version 2 as published by the Free Software Foundation. You should // +//- have received a copy of the GNU General Public License, version 2 // +//- along with the software. If not, see . // +//- // +//- The software is distributed in the hope that it will be useful, but // +//- WITHOUT ANY WARRANTY; without even the implied warranty of // +//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +//- Lesser General Public License for more details. // +//- // +//- You should have received a copy of the GNU Lesser General Public // +//- License along with the software. If not, see // +//- . // +//- // +//- For information regarding this software email: // +//- "Joseph Coffland" // +//- // +//-///////////////////////////////////////////////////////////////////////////// script#tool-view-template(type="text/x-template") #tool - h1 Spindle Configuration + h1 Tool Configuration form.pure-form.pure-form-aligned fieldset templated-input(v-for="templ in template.tool", :name="$key", :model.sync="tool[$key]", :template="templ") + + div(v-if="tool['spindle-type'] == 'PWM'") + h2 PWM Spindle + form.pure-form.pure-form-aligned + fieldset + templated-input(v-for="templ in template['pwm-spindle']", + :name="$key", :model.sync="pwmSpindle[$key]", :template="templ") + + div(v-if="tool['spindle-type'] == 'HUANYANG'") + h2 Huanyang VFD Spindle + form.pure-form.pure-form-aligned + fieldset + templated-input(v-for="templ in template['huanyang-spindle']", + :name="$key", :model.sync="huanyangSpindle[$key]", + :template="templ") diff --git a/src/js/admin-view.js b/src/js/admin-view.js index 3b117a9..d8fc91b 100644 --- a/src/js/admin-view.js +++ b/src/js/admin-view.js @@ -189,6 +189,13 @@ module.exports = { upgrade: function () {this.$dispatch('upgrade')}, + upload: function (e) { + var files = e.target.files || e.dataTransfer.files; + if (!files.length) return; + this.$dispatch('upload', files[0]); + }, + + change_auto_check_upgrade: function () { this.config.admin['auto-check-upgrade'] = this.autoCheckUpgrade; this.$dispatch('config-changed'); diff --git a/src/js/app.js b/src/js/app.js index c3e25a8..ac15dc6 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -65,8 +65,10 @@ module.exports = new Vue({ errorShow: false, errorMessage: '', confirmUpgrade: false, + confirmUpload: false, firmwareUpgrading: false, checkedUpgrade: false, + firmwareName: '', latestVersion: '', password: '' } @@ -81,7 +83,8 @@ module.exports = new Vue({ 'tool-view': require('./tool-view'), 'io-view': require('./io-view'), 'gcode-view': require('./gcode-view'), - 'admin-view': require('./admin-view') + 'admin-view': require('./admin-view'), + 'help-view': {template: '#help-view-template'} }, @@ -123,6 +126,14 @@ module.exports = new Vue({ }, + upload: function (firmware) { + this.firmware = firmware; + this.firmwareName = firmware.name; + this.password = ''; + this.confirmUpload = true; + }, + + error: function (msg) { // Honor user error blocking if (Date.now() - this.errorTimeoutStart < this.errorTimeout * 1000) @@ -169,6 +180,30 @@ module.exports = new Vue({ }, + upload_confirmed: function () { + this.confirmUpload = false; + + var form = new FormData(); + form.append('firmware', this.firmware); + if (this.password) form.append('password', this.password); + + $.ajax({ + url: '/api/firmware/update', + type: 'PUT', + data: form, + cache: false, + contentType: false, + processData: false + + }).success(function () { + this.firmwareUpgrading = true; + + }.bind(this)).error(function () { + alert('Invalid password or bad firmware'); + }.bind(this)) + }, + + show_upgrade: function () { if (!this.latestVersion) return false; return compare_versions(this.config.version, this.latestVersion) < 0; diff --git a/src/js/control-view.js b/src/js/control-view.js index fd08f0b..52b3756 100644 --- a/src/js/control-view.js +++ b/src/js/control-view.js @@ -387,6 +387,16 @@ module.exports = { load_video: function () { this.video_url = '//' + document.location.hostname + ':8000/stream/0?=' + Math.random(); + }, + + + reload_video: function () { + if (typeof this.lastVideoReset != 'undefined' && + Date.now() - this.lastVideoReset < 15000) return; + + this.lastVideoReset = Date.now(); + api.put('video/reload'); + setTimeout(this.load_video, 4000); } } } diff --git a/src/js/tool-view.js b/src/js/tool-view.js index 2df05e4..122babd 100644 --- a/src/js/tool-view.js +++ b/src/js/tool-view.js @@ -35,7 +35,9 @@ module.exports = { data: function () { return { - tool: {} + tool: {}, + pwmSpindle: {}, + huanyangSpindle: {} } }, @@ -48,14 +50,13 @@ module.exports = { }, - ready: function () { - this.update(); - }, + ready: function () {this.update()}, methods: { update: function () { Vue.nextTick(function () { + // Tool if (this.config.hasOwnProperty('tool')) this.tool = this.config.tool; @@ -63,6 +64,24 @@ module.exports = { for (var key in template) if (!this.tool.hasOwnProperty(key)) this.$set('tool["' + key + '"]', template[key].default); + + // PWM + if (this.config.hasOwnProperty('pwm-spindle')) + this.pwmSpindle = this.config['pwm-spindle']; + + template = this.template['pwm-spindle']; + for (key in template) + if (!this.pwmSpindle.hasOwnProperty(key)) + this.$set('pwmSpindle["' + key + '"]', template[key].default); + + // Huanyang + if (this.config.hasOwnProperty('huanyang-spindle')) + this.huanyangSpindle = this.config['huanyang-spindle']; + + template = this.template['huanyang-spindle']; + for (key in template) + if (!this.huanyangSpindle.hasOwnProperty(key)) + this.$set('huanyangSpindle["' + key + '"]', template[key].default); }.bind(this)); } } diff --git a/src/pwr/config.h b/src/pwr/config.h index f17a78f..740065d 100644 --- a/src/pwr/config.h +++ b/src/pwr/config.h @@ -80,6 +80,9 @@ enum { #define VOLTAGE_MIN 11 #define VOLTAGE_MAX 39 #define CURRENT_MAX 25 +#define LOAD_CURRENT_MAX 10.5 +#define CURRENT_OVERTEMP 14 // Should read ~21A but over 11.86A is faulty +#define LOAD_LIMIT_TICKS 10 #define VOLTAGE_SETTLE_COUNT 5 #define VOLTAGE_SETTLE_PERIOD 20 // ms #define VOLTAGE_SETTLE_TOLERANCE 0.01 @@ -125,4 +128,14 @@ enum { OVER_CURRENT_FLAG = 1 << 2, MEASUREMENT_ERROR_FLAG = 1 << 3, SHUNT_OVERLOAD_FLAG = 1 << 4, + MOTOR_OVERLOAD_FLAG = 1 << 5, + + // Non fatal + LOAD1_OVERTEMP_FLAG = 1 << 6, + LOAD2_OVERTEMP_FLAG = 1 << 7, + LOAD1_LIMITING_FLAG = 1 << 8, + LOAD2_LIMITING_FLAG = 1 << 9, }; + + +#define FATAL_FLAG_MASK ((1 << 6) - 1) diff --git a/src/pwr/main.c b/src/pwr/main.c index 3323281..42eae1d 100644 --- a/src/pwr/main.c +++ b/src/pwr/main.c @@ -37,6 +37,20 @@ #include +typedef struct { + regs_t reg; + uint8_t pin; + uint8_t limit; + uint8_t count; + bool shutdown; +} load_t; + +load_t loads[2] = { + {LOAD1_REG, LOAD1_PIN, 0, 0, false}, + {LOAD2_REG, LOAD2_PIN, 0, 0, false}, +}; + + static const uint8_t ch_schedule[] = { TEMP_ADC, VOUT_ADC, VIN_ADC, VOUT_ADC, @@ -49,6 +63,7 @@ static const uint8_t ch_schedule[] = { static volatile uint16_t regs[NUM_REGS] = {0}; static volatile uint64_t time = 0; // ms +static volatile bool motor_overload = false; static volatile bool shunt_overload = false; static volatile float shunt_ms_power = 0; static volatile float vnom = 0; @@ -161,8 +176,44 @@ static void measure_nominal_voltage() { } +static void check_load(load_t *load) { + if (load->shutdown) return; + + // Check overtemp + if (CURRENT_OVERTEMP * 100 < regs[load->reg]) { + IO_PORT_CLR(load->pin); // Lo + IO_DDR_SET(load->pin); // Output + load->shutdown = true; + } + + // Check and adjust limit + if (LOAD_CURRENT_MAX * 100 < regs[load->reg]) { + if (load->limit < LOAD_LIMIT_TICKS) load->limit++; + } else if (load->limit) load->limit--; +} + + +void limit_load(load_t *load) { + if (load->shutdown) return; + + // Limit + if (load->count < load->limit) { + IO_PORT_CLR(load->pin); // Lo + IO_DDR_SET(load->pin); // Output + + } else IO_DDR_CLR(load->pin); // Float + + if (++load->count == LOAD_LIMIT_TICKS) load->count = 0; +} + + ISR(TIMER0_OVF_vect) { static uint8_t tick = 0; + + // Calling these too fast disrupts the I2C bus + if ((tick & 3) == 0) limit_load(&loads[0]); + if ((tick & 3) == 2) limit_load(&loads[1]); + if (++tick == 31) { time++; tick = 0; @@ -197,10 +248,23 @@ static void read_conversion(uint8_t ch) { case TEMP_ADC: regs[TEMP_REG] = data; break; // in Kelvin case VIN_ADC: regs[VIN_REG] = convert_voltage(data); break; case VOUT_ADC: regs[VOUT_REG] = convert_voltage(data); break; - case CS1_ADC: regs[MOTOR_REG] = convert_current(data); break; - case CS2_ADC: regs[VDD_REG] = convert_current(data); break; - case CS3_ADC: regs[LOAD2_REG] = convert_current(data); break; - case CS4_ADC: regs[LOAD1_REG] = convert_current(data); break; + + case CS1_ADC: + regs[MOTOR_REG] = convert_current(data); + if (CURRENT_OVERTEMP * 100 < regs[MOTOR_REG]) motor_overload = true; + break; + + case CS2_ADC: regs[VDD_REG] = convert_current(data); break; + + case CS3_ADC: + regs[LOAD2_REG] = convert_current(data); + check_load(&loads[1]); + break; + + case CS4_ADC: + regs[LOAD1_REG] = convert_current(data); + check_load(&loads[0]); + break; } } @@ -320,12 +384,12 @@ static void shutdown(uint16_t flags) { TCCR0B = TCCR1B = 0; // Disable outputs - IO_DDR_CLR(SHUNT_PIN); - IO_DDR_CLR(MOTOR_PIN); - IO_PORT_CLR(LOAD1_PIN); - IO_PORT_CLR(LOAD2_PIN); - IO_DDR_SET(LOAD1_PIN); - IO_DDR_SET(LOAD2_PIN); + IO_DDR_CLR(SHUNT_PIN); // Input + IO_DDR_CLR(MOTOR_PIN); // Input + IO_PORT_CLR(LOAD1_PIN); // Lo + IO_PORT_CLR(LOAD2_PIN); // Lo + IO_DDR_SET(LOAD1_PIN); // Output + IO_DDR_SET(LOAD2_PIN); // Output while (true) continue; } @@ -367,8 +431,13 @@ int main() { if (VOLTAGE_MAX < vin || VOLTAGE_MAX < vout) flags |= OVER_VOLTAGE_FLAG; if (CURRENT_MAX < get_total_current()) flags |= OVER_CURRENT_FLAG; if (shunt_overload) flags |= SHUNT_OVERLOAD_FLAG; + if (motor_overload) flags |= MOTOR_OVERLOAD_FLAG; + if (loads[0].shutdown) flags |= LOAD1_OVERTEMP_FLAG; + if (loads[1].shutdown) flags |= LOAD2_OVERTEMP_FLAG; + if (loads[0].limit) flags |= LOAD1_LIMITING_FLAG; + if (loads[1].limit) flags |= LOAD2_LIMITING_FLAG; - if (flags) shutdown(flags); + if (flags & FATAL_FLAG_MASK) shutdown(flags); } return 0; diff --git a/src/py/bbctrl/AVR.py b/src/py/bbctrl/AVR.py index a82bb1c..af60741 100644 --- a/src/py/bbctrl/AVR.py +++ b/src/py/bbctrl/AVR.py @@ -87,6 +87,7 @@ class AVR(): ctrl.ioloop.READ) self.i2c_addr = ctrl.args.avr_addr + self._queue_command(Cmd.REBOOT) def _is_busy(self): return self.ctrl.planner.is_running() @@ -216,6 +217,20 @@ class AVR(): continue + # AVR logging + if 'msg' in msg: + level = msg.get('level', 'info') + if 'where' in msg: extra = {'where': msg} + else: extra = None + msg = msg['msg'] + + if level == 'info': log.info(msg, extra) + elif level == 'debug': log.debug(msg, extra) + elif level == 'warning': log.warning(msg, extra) + elif level == 'error': log.error(msg, extra) + + continue + update.update(msg) if update: @@ -261,11 +276,10 @@ class AVR(): row += 1 # Show tool, units, feed and speed - # TODO Units not in state - if 't' in update: self.lcd_page.text('%2uT' % update['t'], 6, 1) - if 'u' in update: self.lcd_page.text('%-6s' % update['u'], 0, 1) - if 'f' in update: self.lcd_page.text('%8uF' % update['f'], 0, 2) - if 's' in update: self.lcd_page.text('%8dS' % update['s'], 0, 3) + if 'tool' in update: self.lcd_page.text('%2uT' % update['tool'], 6, 1) + if 'units' in update: self.lcd_page.text('%-6s' % update['units'], 0, 1) + if 'feed' in update: self.lcd_page.text('%8uF' % update['feed'], 0, 2) + if 'speed' in update: self.lcd_page.text('%8dS' % update['speed'], 0, 3) def connect(self): diff --git a/src/py/bbctrl/Cmd.py b/src/py/bbctrl/Cmd.py index d502b30..9eb623c 100644 --- a/src/py/bbctrl/Cmd.py +++ b/src/py/bbctrl/Cmd.py @@ -34,19 +34,26 @@ import logging log = logging.getLogger('Cmd') -# TODO, sync this up with AVR code -SET = '$' -SET_SYNC = '#' -SEEK = 's' -LINE = 'l' -REPORT = 'r' -PAUSE = 'P' -UNPAUSE = 'U' -ESTOP = 'E' -CLEAR = 'C' -FLUSH = 'F' -STEP = 'S' -RESUME = 'c' +# Keep this in sync with AVR code command.def +SET = '$' +SET_SYNC = '#' +SEEK = 's' +LINE = 'l' +DWELL = 'd' +OUTPUT = 'o' +OPT_PAUSE = 'p' +PAUSE = 'P' +UNPAUSE = 'U' +JOG = 'j' +REPORT = 'r' +REBOOT = 'R' +RESUME = 'c' +ESTOP = 'E' +CLEAR = 'C' +STEP = 'S' +FLUSH = 'F' +DUMP = 'D' +HELP = 'h' SEEK_ACTIVE = 1 << 0 SEEK_ERROR = 1 << 1 diff --git a/src/py/bbctrl/Pwr.py b/src/py/bbctrl/Pwr.py index ff55298..30798ec 100644 --- a/src/py/bbctrl/Pwr.py +++ b/src/py/bbctrl/Pwr.py @@ -42,11 +42,17 @@ LOAD2_REG = 5 VDD_REG = 6 FLAGS_REG = 7 +# Must be kept in sync with pwr firmware UNDER_VOLTAGE_FLAG = 1 << 0 OVER_VOLTAGE_FLAG = 1 << 1 OVER_CURRENT_FLAG = 1 << 2 MEASUREMENT_ERROR_FLAG = 1 << 3 SHUNT_OVERLOAD_FLAG = 1 << 4 +MOTOR_OVERLOAD_FLAG = 1 << 5 +LOAD1_OVERTEMP_FLAG = 1 << 6 +LOAD2_OVERTEMP_FLAG = 1 << 7 +LOAD1_LIMITING_FLAG = 1 << 8 +LOAD2_LIMITING_FLAG = 1 << 9 reg_names = 'temp vin vout motor load1 load2 vdd pwr_flags'.split() @@ -65,19 +71,49 @@ class Pwr(): def get_reg(self, i): return self.regs[i] + def check_fault(self, var, status): + status = bool(status) + + if status != self.ctrl.state.get(var, False): + self.ctrl.state.set(var, status) + if status: return True + + return False + + def error(self): flags = self.regs[FLAGS_REG] - errors = [] - # Decode error flags - if flags & UNDER_VOLTAGE_FLAG: errors.append('under voltage') - if flags & OVER_VOLTAGE_FLAG: errors.append('over voltage') - if flags & OVER_CURRENT_FLAG: errors.append('over current') - if flags & MEASUREMENT_ERROR_FLAG: errors.append('measurement error') - if flags & SHUNT_OVERLOAD_FLAG: errors.append('shunt overload') + if self.check_fault('under_voltage', flags & UNDER_VOLTAGE_FLAG): + log.error('Device under voltage') + + if self.check_fault('over_voltage', flags & OVER_VOLTAGE_FLAG): + log.error('Device over voltage') + + if self.check_fault('over_current', flags & OVER_CURRENT_FLAG): + log.error('Device total current limit exceeded') + + if self.check_fault('measurement_error', + flags & MEASUREMENT_ERROR_FLAG): + log.error('Power measurement error') + + if self.check_fault('shunt_overload', flags & SHUNT_OVERLOAD_FLAG): + log.error('Power shunt overload') + + if self.check_fault('motor_overload', flags & MOTOR_OVERLOAD_FLAG): + log.error('Motor power overload') + + if self.check_fault('load1_overtemp', flags & LOAD1_OVERTEMP_FLAG): + log.error('Load 1 over temperature shutdown') + + if self.check_fault('load2_overtemp', flags & LOAD2_OVERTEMP_FLAG): + log.error('Load 2 over temperature shutdown') + + if self.check_fault('load1_limiting', flags & LOAD1_LIMITING_FLAG): + log.warning('Load 1 limiting active') - # Report errors - if errors: log.error('Power fault: ' + ', '.join(errors)) + if self.check_fault('load2_limiting', flags & LOAD2_LIMITING_FLAG): + log.warning('Load 2 limiting active') def _update(self): diff --git a/src/py/bbctrl/Web.py b/src/py/bbctrl/Web.py index 2d358d9..c6c2f00 100644 --- a/src/py/bbctrl/Web.py +++ b/src/py/bbctrl/Web.py @@ -36,6 +36,7 @@ import shutil import tarfile import subprocess import socket +import time from tornado.web import HTTPError import bbctrl @@ -152,9 +153,13 @@ class FirmwareUpdateHandler(bbctrl.APIHandler): def put_ok(self): - # Only allow this function in dev mode - if not os.path.exists('/etc/bbctrl-dev-mode'): - raise HTTPError(403, 'Not in dev mode') + if not 'password' in self.request.arguments: + raise HTTPError(401, 'Missing "password"') + + if not 'firmware' in self.request.files: + raise HTTPError(401, 'Missing "firmware"') + + check_password(self.request.arguments['password'][0]) firmware = self.request.files['firmware'][0] @@ -234,6 +239,10 @@ class JogHandler(bbctrl.APIHandler): def put_ok(self): self.ctrl.avr.jog(self.json) +class VideoReloadHandler(bbctrl.APIHandler): + def put_ok(self): subprocess.Popen('reset-video').wait() + + # Base class for Web Socket connections class ClientConnection(object): def __init__(self, ctrl): @@ -325,6 +334,7 @@ class Web(tornado.web.Application): (r'/api/override/feed/([\d.]+)', OverrideFeedHandler), (r'/api/override/speed/([\d.]+)', OverrideSpeedHandler), (r'/api/jog', JogHandler), + (r'/api/video/reload', VideoReloadHandler), (r'/(.*)', StaticFileHandler, {'path': bbctrl.get_resource('http/'), "default_filename": "index.html"}), diff --git a/src/resources/config-template.json b/src/resources/config-template.json index bd76c71..bb35333 100644 --- a/src/resources/config-template.json +++ b/src/resources/config-template.json @@ -162,6 +162,31 @@ "default": "false", "code": "sr" }, + "tool-enable-mode": { + "type": "enum", + "values": ["disabled", "lo-hi", "hi-lo", "tri-lo", "tri-hi", "lo-tri", + "hi-tri"], + "default": "lo-hi", + "code": "eom" + }, + "tool-direction-mode": { + "type": "enum", + "values": ["disabled", "lo-hi", "hi-lo", "tri-lo", "tri-hi", "lo-tri", + "hi-tri"], + "default": "lo-hi", + "code": "dom" + } + }, + + "huanyang-spindle": { + "bus-id": { + "type": "int", + "default": "1", + "code": "hi" + } + }, + + "pwm-spindle": { "max-spin": { "type": "float", "unit": "RPM", @@ -176,7 +201,12 @@ "default": 0, "code": "sm" }, - "spin-min-duty": { + "pwm-inverted": { + "type": "bool", + "default": "false", + "code": "pi" + }, + "pwm-min-duty": { "type": "float", "unit": "%", "min": 0, @@ -184,7 +214,7 @@ "default": 1, "code": "nd" }, - "spin-max-duty": { + "pwm-max-duty": { "type": "float", "unit": "%", "min": 0, @@ -199,25 +229,6 @@ "max": 65535, "default": 1000, "code": "sf" - }, - "pwm-inverted": { - "type": "bool", - "default": "false", - "code": "pi" - }, - "tool-enable-mode": { - "type": "enum", - "values": ["disabled", "lo-hi", "hi-lo", "tri-lo", "tri-hi", "lo-tri", - "hi-tri"], - "default": "lo-hi", - "code": "eom" - }, - "tool-direction-mode": { - "type": "enum", - "values": ["disabled", "lo-hi", "hi-lo", "tri-lo", "tri-hi", "lo-tri", - "hi-tri"], - "default": "lo-hi", - "code": "dom" } },