Commit Graph

105 Commits

Author SHA1 Message Date
Jarno Rankinen 21bfe7a9d5 gh-5 Show bitfields correctly again
Bump version to 0.0.3
2023-02-02 13:31:24 +02:00
Jarno Rankinen 64e3a4811a gh-5 Use dom manipulation for coils as well 2023-02-02 13:25:40 +02:00
Jarno Rankinen c29692ae3e gh-5 Improved JS render performance
Dramatically improved web table render time by using dom
manipulation instead of string concatenation for generating the
data table
2023-02-02 13:10:30 +02:00
Jarno Rankinen 5d23e34f44 Include static files in build
Building requires replacing symlinks under static/ with the target file
contents.
2023-02-02 11:44:34 +02:00
Jarno Rankinen 48bdfd691b gh-5 Proper handling of bitfield data type 2023-02-02 00:07:36 +02:00
Jarno Rankinen 1080219b23 gh-5 Handle unsigned & signed values
updateRegisters now handles signed values correctly. Bitfields and
enumerations are still interpreted as unsigned values
2023-02-01 23:09:50 +02:00
Jarno Rankinen 2758f67299 gh-5 Debug/other output 2023-02-01 22:19:57 +02:00
Jarno Rankinen 3990a0a833 gh-5 Register API route somewhat works now
Internal data handling needs much improvement, as signed/unsigned
integers and other data types are not yet handled.

Javascript seems like a really poor choice for parsing the html
table, currently it takes ~10 seconds to hande the data. API
response time is good, so probably switching to Go templates for
the dynamic tables is the best course of action. This will move
the load from clientside to serverside, hopefully the planned
RPi Zero W can handle the computations
2023-02-01 22:12:56 +02:00
Jarno Rankinen 81a7e5cb22 Serve everything from the binary instead of Nginx. Missing TLS, but that may not be a requirement at all 2023-02-01 21:52:55 +02:00
Jarno Rankinen 7eb75541d3 gh-5 Commenting 2023-02-01 00:04:13 +02:00
Jarno Rankinen f4eb787a10 gh-5 Fetch register data from bus
- goburrow/modbus' ReadHoldingRegisters can only fetch 125 registers at a
time, so updateRegisters does several readings
- modbus.ReadHoldingRegisters returns a []byte, where each even byte represents
  the MSB of a int16/uint16 and every odd byte is the LSB
- updateRegisters loops through each response slice forming the 16-bit
  integers

Still need to figure out a way to properly handle the signed/unsigned
values, and also the enumerations and bitfields. Perhaps changing the
'signed' boolean to a byte and making that a bitfield representing the
value type would be a good way to go. The value can then be properly
formed when fetching it from the in-memory pingvinKL struct, while being
stored as an int(64) internally.
2023-02-01 00:03:47 +02:00
Jarno Rankinen 9f2d4b0c29 gh-5 Register data structure
Created preliminary struct for register data, create hreg slice
based on registers.csv
2023-01-31 23:01:09 +02:00
Jarno Rankinen 76d7dd424d #5 Remove extra newlines from registers.csv 2023-01-31 22:59:55 +02:00
Jarno Rankinen 1a8cfe891d gh-5 Created registers.csv from Enervent provided xlsx, change csv delimiter to semicolon 2023-01-31 22:57:14 +02:00
Jarno Rankinen a3bb7aa22e #10 /api/v1/coils content-type to application/json 2023-01-29 23:43:36 +02:00
Jarno Rankinen c45af6d1dd Tidy up log error output 2023-01-29 23:34:43 +02:00
Jarno Rankinen c16f94c6d4 Closes #9 Update coil values on startup. #10 /api/v1/coils route started 2023-01-29 23:31:21 +02:00
Jarno Rankinen 876123e518 #9 Mutex locking for bus operations 2023-01-29 22:09:37 +02:00
Jarno Rankinen 8143414c39 #9 Function to update all coil values 2023-01-29 21:56:22 +02:00
Jarno Rankinen 3fab63f60f #9 Go: Get single coil 2023-01-29 14:42:03 +02:00
Jarno Rankinen 7a8a7ec7bb Python: Fix Lock import 2023-01-29 14:41:25 +02:00
Jarno Rankinen ddfbc4610d Initial steps of go implementation, prime coil data from CSV file 2023-01-28 23:28:37 +02:00
Jarno Rankinen f9035d64c7 Use Lock() instead of Semaphore() 2023-01-20 13:02:52 +02:00
Jarno Rankinen 843cda4b6d Only log bg data update if debug==True 2023-01-18 23:29:08 +02:00
Jarno Rankinen 2a6877cb35 Reduced timeouts, web view page is updated each second and bg data update occurs every 2 seconds. Fired API calls to flip a coil repeatedly with very short intervals, no errors were produced. Closes #2, closes #4 2023-01-18 23:26:24 +02:00
Jarno Rankinen 9cfae44a2f Use plain logging.xxx instead of a class property 2023-01-18 23:14:40 +02:00
Jarno Rankinen 1ae3db957b Switched to serving with Waitress 2023-01-18 23:11:22 +02:00
Jarno Rankinen eb878072d2 #2 Background data updates 2023-01-18 22:57:00 +02:00
Jarno Rankinen d2eeaa1ba0 #4 first implementation of locking for bus communication 2023-01-18 21:25:30 +02:00
Jarno Rankinen 762961e53d Started using GitHub issues & project for keeping track of features, removed TODO comments 2023-01-17 22:13:01 +02:00
Jarno Rankinen 88b17e496f Possibility to use curl to get values in plaintext from document root. Plan is to prepend register list to the output. 2023-01-17 22:08:09 +02:00
Jarno Rankinen 66481d8404 Cleanup 2023-01-17 21:51:24 +02:00
Jarno Rankinen 3fd6669687 Renamed variables, clarified structure 2023-01-17 21:05:31 +02:00
Jarno Rankinen a4a19458f6 /coils and /registers pages symlink to same index.html 2023-01-17 20:44:49 +02:00
Jarno Rankinen 535a6f69e3 Separated html, js and css, moved things to appropriate folders. Need to figure out how to use the same html template for two paths without copying 2023-01-17 20:40:30 +02:00
Jarno Rankinen 6833d9f4d2 NGINX configuration 2023-01-16 23:55:36 +02:00
Jarno Rankinen 1d10a5bbb0 Added index.html, NGINX required 2023-01-16 23:55:02 +02:00
Jarno Rankinen 52ff27b146 Class renaming 2 2023-01-15 23:37:18 +02:00
Jarno Rankinen c2bf84bf90 Renamed class 2023-01-15 23:35:03 +02:00
Jarno Rankinen 595b94a896 PUT /api/v1/coils/<int:address> to flip a coil 2023-01-15 23:32:49 +02:00
Jarno Rankinen 609ae0b97f include_reserved and live moved to query parameters, Coils class is now subscriptable, added a missing reserved coil, Coil class has an individual get() function 2023-01-15 21:46:14 +02:00
Jarno Rankinen 327c3ecd36 minimalmodbus is an attribute of the PingvinKL class now, needs to be passed on to instances of Coil class, Flask routes for reading all coils 2023-01-15 21:05:28 +02:00
Jarno Rankinen 5a9b5a697f First steps for Flask API, print returns a string instead of printing, get() function to get values as JSON array, serialize() function to get values as Python list object 2023-01-15 19:58:30 +02:00
Jarno Rankinen 0b167c31d5 Global debug flag for enervent-logger.py 2023-01-15 15:44:26 +02:00
Jarno Rankinen 74694a6268 Commenting 2023-01-15 15:41:49 +02:00
Jarno Rankinen 281f28fc93 print() function for Coils class 2023-01-15 15:35:41 +02:00
Jarno Rankinen 159b5ec01e Logging tuning 2023-01-15 15:29:52 +02:00
Jarno Rankinen 70976e5bdf updateValue->fetchValue for clarity 2023-01-15 15:25:27 +02:00
Jarno Rankinen 616a25ac4e value and updateValue (read from bus) functions in Coils class 2023-01-15 15:20:21 +02:00
Jarno Rankinen 4826d62477 Rethinking class structure 2023-01-15 14:57:49 +02:00