json output via udp

This commit is contained in:
hg
2015-05-03 20:53:49 +02:00
parent 40e18d4172
commit bbe3e8f9cd
7 changed files with 251 additions and 46 deletions

View File

@ -6,12 +6,10 @@
*/
#include "SimpleModbusMaster.h"
#include "Mudbus.h"
// #include "Mudbus.h"
#include "ModbusApp.h"
enum
{
VOLTAGE,
@ -24,7 +22,8 @@ enum
Packet packets[TOTAL_NO_OF_PACKETS];
Mudbus *modbusSlave;
// Mudbus *modbusSlave;
uint16_t voltage[2];
uint16_t frequency[2];
@ -55,9 +54,10 @@ float getEnergy() { return convF(energy); }
float getNewEnergy() { return convF(energy) - startEnergy; }
void modbusAppBegin(Mudbus *mb) {
// void modbusAppBegin(Mudbus *mb) {
void modbusAppBegin() {
pinMode(ZEROING_PIN, INPUT_PULLUP);
modbusSlave = mb;
// modbusSlave = mb;
modbus_construct(&packets[VOLTAGE], 1, READ_HOLDING_REGISTERS, 0x2000, 2, voltage);
@ -79,15 +79,16 @@ void modbusAppExec() {
startEnergy = nEnergy;
}
modbusSlave->R[0] = voltage[0];
modbusSlave->R[1] = voltage[1];
modbusSlave->R[2] = current[0];
modbusSlave->R[3] = current[1];
modbusSlave->R[4] = frequency[0];
modbusSlave->R[5] = frequency[1];
modbusSlave->R[6] = power[0];
modbusSlave->R[7] = power[1];
modbusSlave->R[8] = energy[0];
modbusSlave->R[9] = energy[1];
// modbusSlave->R[0] = voltage[0];
// modbusSlave->R[1] = voltage[1];
// modbusSlave->R[2] = current[0];
// modbusSlave->R[3] = current[1];
// modbusSlave->R[4] = frequency[0];
// modbusSlave->R[5] = frequency[1];
// modbusSlave->R[6] = power[0];
// modbusSlave->R[7] = power[1];
// modbusSlave->R[8] = energy[0];
// modbusSlave->R[9] = energy[1];
}