GithubHelp home page GithubHelp logo

brewpi / brewpi-script Goto Github PK

View Code? Open in Web Editor NEW
122.0 41.0 83.0 602 KB

This is the repository for the BrewPi Python script. The python script logs the data, monitors the temperature profile and communicates with the BrewPi slave and the web server

Python 88.48% C++ 3.29% Shell 8.21% Batchfile 0.03%

brewpi-script's Introduction

brewpi-script

This is the repository for the BrewPi Python script. The python script logs the data, monitors the temperature profile and communicates with the BrewPi slave and the web server

brewpi-script's People

Contributors

elcojacobs avatar glibersat avatar m-mcgowan avatar niels-r avatar steersbob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brewpi-script's Issues

stdout.txt starts with 292K of NULL bytes after first output

Steps to reproduce:

  1. Let brewpi start with the default CRON command from brewpi.cron:
* * * * * brewpi python /home/brewpi/brewpi.py --checkstartuponly --dontrunfile; [ $? != 0 ] && python -u /home/brewpi/brewpi.py 1>/home/brewpi/logs/stdout.txt 2>>/home/brewpi/logs/stderr.txt &
  1. Erase the logs with the button in the web interface.
  2. Check file size of log files, stdout.txt should be 0 bytes.
  3. Wait for first data point to be logged.
  4. Check file size again: 292K
  5. Check content of stdout.txt with cat -A stdout.txt
...
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@Oct 26 2013 16:44:33  {"BeerTemp": 23.31,"BeerSet":null,"BeerAnn":null,"FridgeTemp": 23.25,"FridgeSet":null,"FridgeAnn":null,"State":0}^M$

This might be caused by python -u (unbuffered). It might not even be bad, but it is weird.

UpdateFirmware.py should use flashDfu.py for the Photon

The current script to update the firmware sends the new firmware over Serial. This does not work for the Photon, where also the system image should be updated.

The photon can be put into DFU mode automatically, so by invoking flashDfu.py --autodfu, the update script can perform the update automatically without user intervention.

fixPermissions.sh hard-coded web value

webPath="/var/www"

echo -e "\n***** Fixing file permissions for $webPath *****"
sudo chown -R www-data:www-data "$webPath"||warn

webPath is hard coded, does not account for a non-default install!

Daemon/Init/Start/Stop to keep brewpi script alive

This is a summary of what has been discussed in the IRC channel and a list of requirements for starting/restarting brewpi.

The old way of doing things (master)

  • The python script brewpi.py is started by the brewpi user's crontab, using this line:
* * * * * python -u /home/brewpi/brewpi.py --dontrunfile 1>/home/brewpi/logs/stdout.txt 2>>/home/brewpi/logs/stderr.txt &

This starts the script unbuffered (-u) and redirects the output to log files.

  • The web interface can stop the script by sending a message over the socket. To prevent CRON from restarting it, it writes a flag file (dontrunfile).
  • The dontrunfile is checked by the script at startup and it exits when it is found.
  • CRON starts the script every minute.
  • At startup, the script uses the python module psutil to check for other running instances. When a conflicting instance is found, it quits. To find conflicts BrewPiProcess.py compares the config's of both scripts to identify conflicts

Motivation

The web server runs as the www-data user and it should not be able to access/execute anything outside of it's own dir and/or usergroup. Stopping the script is no problem, because brewpi is listening on the socket. To start it, the www-data user can just remove the file and wait for the cron job to restart the script as the brewpi user. This keeps the permissions for the www-data user limited.
The brewpi user is a member of the www-data group, but not the other way around.

Limitations

  • Starting the script takes up to a minute. The script is also not restarted immediately after a crash.
  • Modifying the crontab is hard to version control. The current code in develop moved towards using cron.d to solve this issue.
  • psutil does not work on mac. It needs root privileges, but sudo is not transfered to python submodules. So even starting the process with sudo does not work.
  • Each time the cron job executes, it overwrites stdout.txt. This is a bug. I added a command line option to log to files and let python handle redirecting stdout to the file after the startup checks, but I was told this was dirty. Mdma offered a different solution here m-mcgowan@ee503a1 by separating the dontrunfile check from the rest of the code.

The main requirements for the daemon are:

  • When the script crashes, it is restarted automatically (watchdog). It is responsible for logging data and following the temperature profile. A crash could have several causes (hardware fault, communication error, bug in code). Ideally, we except all of them, but we are all programmers that drink a lot ;)
  • BrewPi is started at boot
  • The brewpi service can be started/stopped.
    • This is the main point of discussion. Who should be able to start/restart brewpi?
    • Starting/stopping the script in the web interface might not be a requirement anymore, with the introduction of the feature to stop/pause logging (in develop). When data logging is stopped, brewpi only logs to stderr and stdout files.
    • We need to stop/restart BrewPi for updates
    • Developers need to be able to prevent brewpi from restarting automatically. (eg. sudo service brewpi stop)
  • Changes to the watchdog/init process should be easy to version control
  • Multiple conflicting instances of brewpi should be prevented.
  • Perhaps take into account future implementation of brewpi: In the future, we are likely to ditch apache and to integrate the webserver into python. BrewPi will consists of two (or 3) python scripts, of which the webserver is always running. A likely implementation is that each Arduino is wrapped by a driver script. Another process communicates with these drivers. The data logger could be a separate process as well.

Our options so far:

So now we have a place to discuss this properly. I don't know much about this topic, so your opinions are very welcome.

updater.py bug

No time to troubleshoot what caused it right now, but ran updater.py:

I'll look more into it later tonight


Checking for updates on //github.com/BrewPi/brewpi-www, branch master
Your local copy of //github.com/BrewPi/brewpi-www is current as of: Date: Tue Jun 25 15:50:16 2013 +0200
The most current version of BrewPi for this branch is Date: Tue Jun 25 15:50:16 2013 +0200
Your local version of //github.com/BrewPi/brewpi-www is good to go!
Traceback (most recent call last):
File "./updater.py", line 204, in
if mod:
NameError: name 'mod' is not defined

Print warning or ask when arduino dir is not found.

Our policy is to load the tool locations from the config file, but when they are not set assume default locations.

If these default locations don't have the tools, we should warn, print the issue at hand and how to correct it (instructions to edit config.cfg), instead of crashing.

Relevant piece of code:
https://github.com/BrewPi/brewpi-script/blob/master/programArduino.py#L66

Current behavior:

result of invoking avrdude:
/bin/sh: 1 arduinohome/hardware/tools/avrdude: not found

The script continues , gives the countdown,etc. and eventually tells me that it "Cannot receive version number".

Or:

When I try with programArduinoFirstTime.py ...

**** Arduino Program script started ****

Settings will be restored if possible

Devices will be restored if possible

Checking old version before programming.

Warning: Cannot receive version number from Arduino. Your Arduino is either not programmed yet or running a very old version of BrewPi. Arduino will be reset to defaults.

Loading programming settings from board.txt

Checking hex file size with avr-size...

Traceback (most recent call last):
File "programArduinoFirstTime.py", line 39, in
result = programmer.programArduino(config, boardType, hexFile, {'settings': True, 'devices': True})
File "/home/brewpi/programArduino.py", line 171, in programArduino
' bytes out of max ' + boardSettings['upload.maximum_size']))
KeyError: 'upload.maximum_size'

Reported here:
http://forum.brewpi.com/discussion/553/need-help-programming-arduino

python script isue when looking at web interface

I have installed the brew pi software onto my rasbary PI there was no present errors during the install but when I got to start the script in the online interface I am not able to. The error online reads Cannot receive LCD text from Python script. Please advise of how to resolve this issue.

Thank you
Daniel Rosin
brew pi screen shoot

CI build on jenkins needed

The codebase already includes a handful of unit tests, and will include more as coding continues. These tests should naturally be part of the CI build.

The CI build will be needed on multiple branches, e.g. the current develop and the new branch for the rewrite.

wifichecker should only be active when WiFi dongle found

The WiFi checker tries to activate wlan0 and prints errors when no WiFi module has been plugged in.
It would be better to check for the existance of the module and just exit silently when it cannot be found. Trying to do things against wlan0 when the module is not plugged in is silly.

Error in stderr:

wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return code 1
Cannot find device "wlan0"

BrewPiProcess.py 108 TypeError: 'instancemethod' object is not iterable

Attempting to run BrewPi in arch on raspberry, I am not sure if the versions of libraries are different for the intended target distribution & arch. I am getting some errors after manually installing dependencies.

BrewPiProcess.py", line 108, in update
matching = [p for p in psutil.process_iter() if any('python' in p.name and 'brewpi.py'in s for s in p.cmdline)]
TypeError: 'instancemethod' object is not iterable

Can easily be fixed if changed as below, not sure if it will break other distributions. (Going to assemble my shield kit over next few days so should be able to test further on this distribution)

108c108

< matching = [p for p in psutil.process_iter() if any('python' in p.name() and 'brewpi.py'in s for s in p.cmdline())]

    matching = [p for p in psutil.process_iter() if any('python' in p.name and 'brewpi.py'in s for s in p.cmdline)]

124c124

< cfg = [s for s in process.cmdline() if '.cfg' in s] # get config file argument

    cfg = [s for s in process.cmdline if '.cfg' in s]  # get config file argument

Thanks,

John

How to update

Here is a high-level overview of how I think we could organize the updates better:

user runs ./updater.py

  • updater.py checks for new updates, and allows user to download (feature already present in existing code). If updates are installed, it well prompt the user to run installUpdate.py

in brewpi-script repo, there is a file 'installUpdate.py'
installUpdate.py will:

  • import 'installDependencies.py' (yes, py) and run updateDependencies() to install dependencies
  • take care of whatever other changes need to happen external to the git dir
  • examine cron to find and, if necessary, replace the single line in the crontab
  • (future:) copy the most recent version of brewpi initscript to the init.d directory (instead of the crontab method)
  • restart BrewPi
    *** I could argue this should be a shell script, as the paths it will likely be using are linux-specific, but by keeping it as pythin, I think this can be used as a platform that we could eventually do OS-checking on, and use it to perform windows-specific commands. (Platform-agnostic)

What else should go in installUpdate.py ?

This will allow you a scaleable platform from which you can easily incorporate future changes into, and more importantly, control those changes, especially outside the git directory. This way, all updater.py is doing is pulling down the most recent code, from which you can launch the installer.

Let's discuss some more, and I can whip out some code, but I'm getting bored of writing code that isn't used :P

Write to do_not_run_file?

Around line 501 in the dev branch:

                   dontrunfile = open(dontRunFilePath, "w")
                    dontrunfile.write("1")
                    dontrunfile.close()

Do we actually need to write a 1 there? All we're doing elsewhere in the script is checking if the file exists, and using that as our logic. We never read the file. I think we can pull this out, unless there is another reason to include this

crontab line referring to wifiChecker.sh is missing after updating

Updater.py asks the user to install wifiChecker and echoes the apropriate line to /etc/cron.d/brewpi (through wifiCheker.sh install).
When finishing update, /etc/cron.d/brewpi is overwritten by /home/brewpi/utils/brewpi.cron which contains only the line for brewpi script (updater.py->runAfterUpdate.sh->updateCron.sh)

Install.py on the other hand, calls first updateCron.sh and then installs additional line for wifiChecker.sh

I guess the ifconfig section that asks the user about installing wifi-checker should be removed from install.sh and updater.py and go only to updateCron.sh

UnboundLocalError: local variable 'line' referenced before assignment

(brewpi)[rbrady@localhost utils]$ sudo python flash_dfu.py --tag 0.3.0a --autodfu
[sudo] password for rbrady:
Will try to download release '0.3.0a'
Will automatically reboot newly detected photons into DFU mode
Detecting DFU devices
Did not find any DFU devices.
Is your Photon or Spark Core running in DFU mode (blinking yellow)?
Waiting until a DFU device is connected...
Found new serial port connected: ('/dev/ttyACM9', 'Particle Photon')
Putting Photon in DFU mode
Found 1 devices: ['2b04:d006']
Device identified as Particle Photon
Downloading latest firmware...
downloading https://github.com/BrewPi/firmware/releases/download/0.3.0a/brewpi-0.3.0a-photon.bin
Firmware downloaded to /home/rbrady/brewpi-script/utils/downloads/0.3.0a/brewpi-0.3.0a-photon.bin
downloading https://github.com/BrewPi/firmware/releases/download/0.3.0a/system-part1-09dd809-photon.bin
downloading https://github.com/BrewPi/firmware/releases/download/0.3.0a/system-part2-09dd809-photon.bin
Release contains updated system firmware for the photon
First updating system firmware for the Photon
dfu-util 0.7

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to [email protected]

Filter on vendor = 0x2b04 product = 0xd006
Opening DFU capable USB device... ID 2b04:d006
Run-time device DFU version 011a
Found DFU: [2b04:d006] devnum=0, cfg=1, intf=0, alt=0, name="@internal Flash /0x08000000/03_016Ka,01_016Kg,01_064Kg,07_128Kg"
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
No valid DFU suffix signature
Warning: File has no DFU suffix
DfuSe interface name: "Internal Flash "
Downloading to address = 0x08020000, size = 248764
.............................................................
File downloaded successfully
dfu-util 0.7

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to [email protected]

Filter on vendor = 0x2b04 product = 0xd006
Opening DFU capable USB device... ID 2b04:d006
Run-time device DFU version 011a
Found DFU: [2b04:d006] devnum=0, cfg=1, intf=0, alt=0, name="@internal Flash /0x08000000/03_016Ka,01_016Kg,01_064Kg,07_128Kg"
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuDNLOAD-IDLE, status = 0
aborting previous incomplete transfer
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
No valid DFU suffix signature
Warning: File has no DFU suffix
DfuSe interface name: "Internal Flash "
Downloading to address = 0x08060000, size = 150432
.....................................
File downloaded successfully
Now writing BrewPi firmware /home/rbrady/brewpi-script/utils/downloads/0.3.0a/brewpi-0.3.0a-photon.bin
dfu-util 0.7

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to [email protected]

Filter on vendor = 0x2b04 product = 0xd006
Opening DFU capable USB device... ID 2b04:d006
Run-time device DFU version 011a
Found DFU: [2b04:d006] devnum=0, cfg=1, intf=0, alt=0, name="@internal Flash /0x08000000/03_016Ka,01_016Kg,01_064Kg,07_128Kg"
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuDNLOAD-IDLE, status = 0
aborting previous incomplete transfer
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
No valid DFU suffix signature
Warning: File has no DFU suffix
DfuSe interface name: "Internal Flash "
Downloading to address = 0x080a0000, size = 58164
...............
File downloaded successfully
Error during download get_status
Error during download get_status
Programming done, now resetting EEPROM to defaults
Opening serial port
Aug 08 2015 16:58:24 Opening serial port
Traceback (most recent call last):
File "flash_dfu.py", line 203, in
programmer.fetch_version("Success! ")
File "/home/rbrady/brewpi-script/utils/../program_controller.py", line 296, in fetch_version
version = brewpi_version.getVersionFromSerial(self.ser)
File "/home/rbrady/brewpi-script/utils/../brewpi_version.py", line 39, in getVersionFromSerial
if line:
UnboundLocalError: local variable 'line' referenced before assignment

Chart overlap with daylight savings and auto time adjust

Tim Malstrom reported this behavior on the forum:
daylight-savings-bug

Quote:
"@eLco Ah, now I know what caused it! When looking in the CSV file, I saw that this particular hour had a list of data points logged twice (after 02:59, it started all over again at 02:00). Looking back in my calendar made me realize that the raspberry Pi clock had been set back automatically due to Daylight saving time in Sweden at that exact time. Odd one!"

Pushing data to external database

Do you have any tips where i should look for the data if i want to push the live temperature data to an external server.
I wish to make a separate python file with a couple if functions thats ment to push data to an external server each time the brewpi records it, say every 10 sec.
Any suggestion where this should be added?

Print different message on program script failure

The main script always prints "New program uploaded to Arduino, script will restart" after running the programmer.

It should check the return value of the script and print a different message on failure.

Linux port of testTerminal.py

testTerminal.py (https://github.com/BrewPi/brewpi-script/blob/develop/testTerminal.py) opens a serial port to the Arduino and expands the log messages it receives.

The current implementation uses msvcrt for non-blocking user input. This is a windows-only module.

It would be great to have an easily interact with the Arduino on Linux as well.

Of course '''screen /dev/ttyACM0 57600" works, but with the log messages not being expanded, it it hard to interpret the serial output.

wifiChecker log message format is inconsistent

Update wifiChecker.sh with log messages matching basic date-first format.
simply use following as an example perhaps, setting INFO/WARNING/ERROR as appropriate?

echo "$(date +"%b %d %Y %T") ERROR BrewPi: wifiChecker: This script must be run as root: sudo ./wifiChecker.sh" 1>&2

instead of
echo "This script must be run as root: sudo ./wifiChecker.sh) ($(date))" 1>&2

Rename and refactor programArduinoFirstTime

The programArduinoFirstTime script is not used anymore to program a blank Arduino, but an updated version of it can still be useful when the main script cannot run properly.

I think it could be renamed to programManually.py or something similar and can take command line arguments instead of the hardcoded hex file, port, etc.

Change cron job to redirect output of wifichecker to stdout.txt as BrewPi user

William helped me find this well hidden bug on the IRC channel.

The cron job to run the wifichecker is run as root, but it also appends to /home/brewpi/logs/stdout.txt

If the wifichecker creates the file, it is owned by root.

The cron job to restart the brewpi script will fail, because of the file permissions and BrewPi will never restart.

To fix this bug, the cron line that executes the wifi checker has to be changed so it will create stdout.txt owned by brewpi.
The wifichecker has to run as root (to be able to do some magic to restart wifi), but the redirect has to run as brewpi. Perhaps piping to tee is a possible fix.

Cron management

I think we can do cron management a little bit better, and as a result of changes here, better support the program in other locations as well.

Global settings file

To begin, I propose creating a ~/settings/.brewpisettings file to hold common variables we already repeatedly ask for in the install and upgrade process (and other places as well). By placing this file in a standard location, the multiple brewpi scripts could reference (from any repo) without having to import an entire module from a differenet repo, or hack-ily parse through other code. It would hold:

  • webPath - path to brewpi web install location
  • scriptPath - path to brewpi-script install location
  • Hexfile version - current version of the hex file loaded on Arduino
  • board version - model of Arduino board being used
  • modules present to be loaded - in this case, brewpi.py, wifichecker.sh, and maybe bubblecounter.whatever
  • stdout logging path - path to stdout log file
  • stderr logging path - path to stderr log file
    ... and anything else that we reuse I haven't though of yet.

At first, I thought about pushing the entire brewpi settings file currently being used to /etc/brewpi, but I think this will cause significant issues with configuration management as updates are made to the config file, or the user changes it. Instead, I suggest creating a sym-link in /etc/brewpi/settings to wherever the settings file is installed. This way, any script can universally reference /etc/brewpi/settings to get its important data, no matter where the user has installed brewpi. This additionally allows us to make changes to the config file locally via the git repo without needing to update a file outside the repo.

Module requirements

A module will take one of four arguments from stdin when run:

  • null: Run the module
  • install: install the module
  • cron: return the cron line that should be used in cron.d
  • remove: optional, but good to have it in the plan

Installing a module

For cronUpdate.sh , I strongly disagree with putting the install code for each module into cronUpdate.sh .

The goal of modularity is pushing as much code specific to a module, out to the module itself. Think of how aptitude updates run, or installing a python module- the install code for each new package is not contained within the main program- you merely pass an install argument to the code it has downloaded, and the package takes care of the rest. For wifichecker, its only a few lines, but as modules become more advanced, so too may become the install code. You don't want to carry around that amount of code for modules some users may never use (and especially if the modules eventually get pushed to their own repo).

Instead, when called by cronUpdate.sh with the 'install' argument (and root privs), the module will take care of adding itself to cron.d, updating its entry in the .settings file as 'true', and moving files anywhere they may need to be. There will also need to be an install path variable for each entry

Tracking/Updating modules

To update modules, updateCron cycles through the list of installed modules in .settings, checks which vars are true, and compares (version number? md5 hash? cron line?) of a module and, if different, prompts to update.
-OR-
cycle through each installed module and just overwrite the cron file with each new entry (starting with brewpi)

I don't want to be prompted to install old modules I already said no to!

updateCron has a 'master' list of all potential modules within it. (This is the only module-specific code located in updateCron) When it scans .settings to update, any entries that exist within the master list but not the .settings file will cause the user to be prompted to install that module. If they choose 'yes', the module is installed, and an entry is made to the .settings file with moduleName = True. If the user choose not to install, an entry is made to .settings with moduleName = False, and that module is not prompted to the user for install again on future updates.

updateCron psuedocode

read in all modules listed in .settings file
retrieve current cron lines from each installed module
compare to installed cron.d lines, replace if necessary (or straight overwrite everytime)
prompt user to install any newly-added modules not seen before
restart cron
Profit!

Bottom line

I think this framework for modules / cron

  • gives us a format that future modules should adhere to
  • pushes as much unique/module-specific code out to the module as possible
  • promotes code re-use by brewpi
  • prevents extensive changes to 'core' code (updateCron.sh) as each module is added (only adding a variable name to check for, nothing extensive or bulky)
  • enables commonly-used variables to be used from a static location
  • don't need to create backward-compatibility checks for the 'new' cron file version

Lets discuss!

brewpi.py --status does not read default user config

When brewpi is started (manually or by cron) without specifying a user config file, it loads /home/brewpi/settings/config.cfg

BrewPiProcess checks if a config file is loaded here:
https://github.com/BrewPi/brewpi-script/blob/master/BrewPiProcess.py#L124

The check however depends on the cmdline used to start BrewPi.
When BrewPi is started without specifying a config file, it still loads user settings from config.cfg.

These are not loaded when the config is read in BrewPiProcess:
https://github.com/BrewPi/brewpi-script/blob/master/BrewPiProcess.py#L127

BrewPi process is therefore unaware of the settings in config.cfg

BrewPiProcess.py 108 TypeError: 'instancemethod' object is not iterable

Attempting to run BrewPi in arch on raspberry, I am not sure if the versions of libraries are different for the intended target distribution & arch. I am getting some errors after manually installing dependencies.

BrewPiProcess.py", line 108, in update
matching = [p for p in psutil.process_iter() if any('python' in p.name and 'brewpi.py'in s for s in p.cmdline)]
TypeError: 'instancemethod' object is not iterable

Can easily be fixed if changed as below, not sure if it will break other distributions. (Going to assemble my shield kit over next few days so should be able to test further on this distribution)

108c108
<         matching = [p for p in psutil.process_iter() if any('python' in p.name() and 'brewpi.py'in s for s in p.cmdline())]

---
>         matching = [p for p in psutil.process_iter() if any('python' in p.name and 'brewpi.py'in s for s in p.cmdline)]
124c124
<         cfg = [s for s in process.cmdline() if '.cfg' in s]  # get config file argument

---
>         cfg = [s for s in process.cmdline if '.cfg' in s]  # get config file argument

Thanks,

John

When multiple serial messages are received in one blob, only the first one is processed and the rest left in the buffer

Incoming serial data is read in a background thread. On incoming serial data, this background thread checks the buffer to find occurrences of \n to see if any complete lines are received and adds these to a queue.
The bug was that on each blob or incoming serial data, it only did this once. So if multiple lines were received in one blob, it would only process the first one and leave the rest in the buffer. It would only process the line it left when a new blob came in.

I think this went unnoticed with the previous versions of the firmware, because it was slower and it was unlikely that multiple lines were received in 0.01 seconds.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.