implementation of parts of the unilynx protocol, for communicating with danfos photovoltaic inverters. Still BETA ! needs byte stuff/unstuff fixed, and some CRC are left out for niw...
Diff: main.cpp
- Revision:
- 1:df4e9da66448
- Parent:
- 0:66a099b01e08
- Child:
- 2:de090b60d543
--- a/main.cpp Mon Aug 27 18:30:37 2012 +0000 +++ b/main.cpp Tue Aug 28 19:53:42 2012 +0000 @@ -1,22 +1,39 @@ #include "mbed.h" #include "unilynx.h" - +Serial pc(USBTX, USBRX); DigitalOut myled(LED1); -int main() { -rs485init(); - while(1) { - //test(); - readParameter(RAW_MEAS_VALUES, ENERGY_PRODUCTION); +int current_production_avg; +int current_production; +int today_production; +int total_production; + +int main() +{ + /* setup terminal */ + pc.baud(115200); + /* setup RS485 */ + rs485init(); - #if 1 -// ping(); - myled = 1; - wait(1); - myled = 0; -// getNodeInfo(); - wait(1); - #endif + while(1) + { + /* read parameters of interest */ + total_production = readParameter(RAW_MEAS_VALUES, ENERGY_PRODUCTION, ID_RAW_MEAS_VALUES); + pc.printf("Production Total: %d [Wh]\n",total_production); + today_production = readParameter(RAW_MEAS_VALUES, ENERGY_PRODUCTION_TODAY, ID_RAW_MEAS_VALUES); + pc.printf("Production Today: %d [Wh]\n",today_production); + //current_production_avg = readParameter(RAW_SMOOTH_VALUES, INSTANT_ENERGY, ID_RAW_SMOOTH_VALUES); + current_production = readParameter(RAW_MEAS_VALUES, INSTANT_ENERGY, ID_RAW_MEAS_VALUES); + //pc.printf("Production Now: %04d [W] Avg.: %04d [W] \n",current_production,current_production_avg); + pc.printf("Production Now: %04d [W] \n",current_production); + + /* print to console*/ +/* pc.printf("Production Total: %d [Wh]\n",total_production); + pc.printf("Production Today: %d [Wh]\n",today_production); + pc.printf("Production Now: %04d [W] \n",current_production); +*/ + wait(3); + } }