Code Monkey home page Code Monkey logo

apparatus-templi's Introduction

apparatus-templi

Home automation

apparatus-templi's People

Contributors

ciasaboark avatar christopherhagler avatar kimberlyriley avatar terrence92 avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

apparatus-templi's Issues

Remove auto-detect serial port

Auto-detecting the serial port the local arduino is connected to is problematic. Simplify design by only connecting to the serial port named in the config file or on the command line.

Defaulting to the dummy serial connection will allow the service to be run without any hardware attached.

SQLite database will sometimes fail

Seems to be a different problem then #11.
Occasionally calls to storeTextData() or storeBinData() will generate a SQLException.
Hard to reproduce, only occurs once between a few hundred to a few thousand writes, sometimes not at all.

Deadlock on serial read/write

System will deadlock if multiple threads try to send/receive messages at the same time. Do not run the system with more than one driver active for now. Disable as many response messages from the remote modules as possible.

Command line options are not read

Coordinator.parseCommandLineOptions() only looks for a few options, but running with —help will list a large number of possible options. Either these should be removed, or they should all be parsed.

Arduino Code

Check on:

  1. https://github.com/ciasaboark/apparatus-templi/blob/master/skeleton/arduino-sketches/lazy_sensor/lazy_sensor.ino#L254: for loss of precision.

  2. https://github.com/ciasaboark/apparatus-templi/blob/master/skeleton/arduino-sketches/lazy_sensor/lazy_sensor.ino#L223
    change to this so it can do away with the memcpy
    byte fragmentBytes[sizeof(int)];
    fragmentBytes = &fragmentNO;
    payload[3] = fragmentBytes[1];
    payload[4] = fragmentBytes[0];

  3. https://github.com/ciasaboark/apparatus-templi/blob/master/skeleton/arduino-sketches/lazy_sensor/lazy_sensor.ino#L260 , https://github.com/ciasaboark/apparatus-templi/blob/master/skeleton/arduino-sketches/lazy_sensor/lazy_sensor.ino#L227 , can do away with the for loop and just use memset to zero out the array if the memset function is available to the arduino code.

  4. https://github.com/ciasaboark/apparatus-templi/blob/master/skeleton/arduino-sketches/lazy_sensor/lazy_sensor.ino#L264 change the int to bytes or shorts to conserve space. The int is 2 bytes on the arduino, so it could save space if it is needed.

  5. I would also try and change the parameters to use addresses instead of values, copying and passing arrays by value is alot of overhead. https://github.com/ciasaboark/apparatus-templi/blob/master/skeleton/arduino-sketches/lazy_sensor/lazy_sensor.ino#L216: change to: void sendCommandFragment(String *commandFragment, int fragmentNo)

Remove config file overwrite check

The service does not allow saving a config file with the same name as the default config file (to prevent accidental overwrites). This check should be removed, since the default config file will be packaged within the jar, and will not be overwritten.

-handler to save preferences will need to be updated to avoid checking file name collisions.
-default preferences file should be removed (default preferences are declared programmatically within Prefs anyway).
-make sure read prefs pulls from Prefs.DEF_PREFS instead of the default preferences file.

Web server can not bind to same port when restarting service

Seems to be windows specific for now.
Start the service as usual, use web interface to restart service. Drivers will terminate, web server will terminate, but new web server instance can not bind to same port
-- log

1394931511475: SimpleHttpServer:received request from /192.168.0.102:52149 GET: '/restart_module?module=all'
1394931511490: Coordinator:restarting all modules
1394931511491: Coordinator:restarting drivers
1394931511492: Coordinator:restarting all drivers
1394931511492: Coordinator:removing all event watchers
1394931511493: Coordinator:terminating driver XmlTest
1394931511493: Coordinator:waking driver XmlTest
1394931511494: Coordinator:terminating driver LOCAL
1394931511494: Coordinator:waking driver LOCAL
1394931511495: Coordinator:terminating driver LED_FLASH
1394931511495: Coordinator:waking driver LED_FLASH
1394931516496: Coordinator:driver LED_FLASH terminated
1394931516496: Coordinator:driver XmlTest terminated
1394931516496: Coordinator:driver LOCAL terminated
1394931516516: Warning: Coordinator:all drivers stopped
Coordinator:Initializing drivers...
1394931516517: Coordinator:driver LOCAL of type org.apparatus_templi.driver.Local initialized
1394931516517: Coordinator:driver LED_FLASH of type org.apparatus_templi.driver.LedFlash initialized
1394931516518: Coordinator:driver XmlTest of type org.apparatus_templi.driver.XmlTest initialized
Coordinator:Starting driver XmlTest
Coordinator:Starting driver LOCAL
Coordinator:Starting driver LED_FLASH
1394931516518: Coordinator:restarting web server
1394931516519: LOCAL:starting
1394931516520: LED_FLASH:starting
1394931516530: SimpleHttpServer:terminating
Coordinator:Starting web server on port 8000 bound to localhost address 192.168.0.101
1394931517521: SimpleHttpServer:port number 8000 not available
1394931517521: TERMINAL FAILURE: Coordinator:could not start web server on port 8000
1394931517524: Coordinator:system is going down. Notifying all drivers.
1394931517525: Coordinator:terminating driver 'XmlTest'
1394931517526: Coordinator:notified driver 'XmlTest'
1394931517526: Coordinator:terminating driver 'LOCAL'
1394931517528: Coordinator:notified driver 'LOCAL'
1394931517528: Coordinator:terminating driver 'LED_FLASH'
1394931517529: Coordinator:notified driver 'LED_FLASH'

Service does not exit cleanly

If the service goes down (either from the system tray, ctrl-c, etc.) it should send out an email (if possible), then cleanly exit. Right now the service hangs indefinitely, and must be killed manually.

Default configuration file can be overwritten from web interface

The web interface should not be able to overwrite the default config file. Right now the javascript only checks that the new config file name exactly matches the default config file name. If the two match the button is disabled. If the user changes the config file name to ./coordinator.conf then the name will not match, but the file referenced will be the default config. It will be hard to check this in the javascript, so it should be patched in the backend code.

Prefs.savePreferences() should check based on the resolved file name instead of doing a direct string comparison.

SQLite database will sometimes fail during nested queries

Methods to store data make a call to read data to see whether previous data has been stored. This results in two connections to the database being open at the same time. Most of the time this works fine, but sometimes the call to getConnection() will generate a SQLException which throws a NullPointerException.

Possible fixes:
-issue read query inline, without opening a new connection
-keep reference to connection as class member instead of generating a new one on the heap

Relevant log:

1394763490464: DB_TESTER:Test 29 of 100
1394763490464: Coordinator:storeBinData()
1394763490465: DatabaseService:storing binary data
1394763490479: DatabaseService:reading binary data
1394763490482: Error: DatabaseService:unable to get connection to database, will try again
1394763490682: Error: DatabaseService:unable to get connection to database, will try again
1394763490882: Error: DatabaseService:unable to get connection to database, will try again
<repeats indefinitely>

Replace settings handler with xml

The web server should present current settings as xml data (how would this work for passwords?). The settings handler should be replaced or supplemented with another handler that returns the current preferences as xml so that the front ends can format the data as needed.

Ant script

Ant build script needs to be written so that distribution packages can be generated.

isModulePresent() does not properly match strings

For whatever reason isModulePresent() does not match two strings that should match. i.e. 'LOCAL'.equals('LOCAL') will fail. Probably something to do with reading in the destination string from the message as utf-8 instead of unicode.

Javascript should be broken into multiple files

main.js needs to be broken into multiple files so that only the appropriate parts are loaded for each page.

Will need to update template so that javascript links can be inserted into header.
Will need to update handlers so that appropriate javascript links are inserted into header.

Remove automatic port selection from web server

Auto-detecting port numbers is problematic, and was introduced to get around limitations on re-binding to the same port when restarting the web server. Since the server now re-uses the same socket whenever possible it no longer serves any use. The web server should bind to either the default port, the port number specified in the config file, or the port number specified as a command line option (in increasing precedence). If that port number can not be bound to, the service should terminate.

Basic web-server completed

Web server capable of listening for incoming request from a single client and returning formatted xml based on responses from Coordinator API.

Can not set blank field in settings

setting a field blank in the setting.html and trying to save the settings will now work. Server will respond with no data before closing the connection. Check that breaking the query string into key/value pairs can deal with this

Add proper logging

Update Log class to write logging messages to a log file instead of printing to STDOUT

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.