Hello,
I'm trying the Konnekting library for the first time. I tested the communicationTest sketch, and it worked fine.
Now I tried to implement it into a bigger project, but nothing happens, serial moniter is blanked out.. It should print lots of info on the TX/RX buffer I'm sending to the heatpump. It seems like the sketch never reaches the loop.
If I comment away the KNX-parts, the sketch works fine polling info from the heat-pump and print it on serial monitor.
The board seem to reboot in loop, it never prints the "Setup complete" on the serial monitor.
Anyone have any idea, what I'm doing wrong?
Sorry for 800 lines of code..
I'm trying the Konnekting library for the first time. I tested the communicationTest sketch, and it worked fine.
Now I tried to implement it into a bigger project, but nothing happens, serial moniter is blanked out.. It should print lots of info on the TX/RX buffer I'm sending to the heatpump. It seems like the sketch never reaches the loop.
If I comment away the KNX-parts, the sketch works fine polling info from the heat-pump and print it on serial monitor.
The board seem to reboot in loop, it never prints the "Setup complete" on the serial monitor.
Anyone have any idea, what I'm doing wrong?

Sorry for 800 lines of code..
Code:
#include <REGO637.h> #include <Arduino.h> // required before wiring_private.h #include "wiring_private.h" // pinPeripheral() function #include <KonnektingDevice.h> #define NUM_SYSTEMREGS 52 #define NUM_FRONTPANEL 5 #define KNX_SERIAL Serial // D0=RX/D1=TX #define TEST_LED A5 // On board LED on pin D13 #define DEBUGSERIAL SerialUSB // USB port word individualAddress = P_ADDR(1, 1, 62); word groupAddressOutput0 = G_ADDR(7, 1, 0); word groupAddressOutput1 = G_ADDR(7, 1, 1); word groupAddressOutput2 = G_ADDR(7, 1, 2); word groupAddressOutput3 = G_ADDR(7, 1, 3); word groupAddressOutput4 = G_ADDR(7, 1, 4); word groupAddressOutput5 = G_ADDR(7, 1, 5); word groupAddressOutput6 = G_ADDR(7, 1, 6); word groupAddressOutput7 = G_ADDR(7, 1, 7); word groupAddressOutput8 = G_ADDR(7, 1, 8); word groupAddressOutput9 = G_ADDR(7, 1, 9); word groupAddressOutput10 = G_ADDR(7, 1, 10); word groupAddressOutput11 = G_ADDR(7, 1, 11); word groupAddressOutput12 = G_ADDR(7, 1, 12); word groupAddressOutput13 = G_ADDR(7, 1, 13); word groupAddressOutput14 = G_ADDR(7, 1, 14); word groupAddressOutput15 = G_ADDR(7, 1, 15); word groupAddressOutput16 = G_ADDR(7, 1, 16); word groupAddressOutput17 = G_ADDR(7, 1, 17); word groupAddressOutput18 = G_ADDR(7, 1, 18); word groupAddressOutput19 = G_ADDR(7, 1, 19); word groupAddressOutput20 = G_ADDR(7, 1, 20); word groupAddressOutput21 = G_ADDR(7, 1, 21); word groupAddressOutput22 = G_ADDR(7, 1, 22); word groupAddressOutput23 = G_ADDR(7, 1, 23); word groupAddressOutput24 = G_ADDR(7, 1, 24); word groupAddressOutput25 = G_ADDR(7, 1, 25); word groupAddressOutput26 = G_ADDR(7, 1, 26); word groupAddressOutput27 = G_ADDR(7, 1, 27); word groupAddressOutput28 = G_ADDR(7, 1, 28); word groupAddressOutput29 = G_ADDR(7, 1, 29); word groupAddressOutput30 = G_ADDR(7, 1, 30); word groupAddressOutput31 = G_ADDR(7, 1, 31); word groupAddressOutput32 = G_ADDR(7, 1, 32); word groupAddressOutput33 = G_ADDR(7, 1, 33); word groupAddressOutput34 = G_ADDR(7, 1, 34); word groupAddressOutput35 = G_ADDR(7, 1, 35); word groupAddressOutput36 = G_ADDR(7, 1, 36); word groupAddressOutput37 = G_ADDR(7, 1, 37); word groupAddressOutput38 = G_ADDR(7, 1, 38); word groupAddressOutput39 = G_ADDR(7, 1, 39); word groupAddressOutput40 = G_ADDR(7, 1, 40); word groupAddressOutput41 = G_ADDR(7, 1, 41); word groupAddressOutput42 = G_ADDR(7, 1, 42); word groupAddressOutput43 = G_ADDR(7, 1, 43); word groupAddressOutput44 = G_ADDR(7, 1, 44); word groupAddressOutput45 = G_ADDR(7, 1, 45); word groupAddressOutput46 = G_ADDR(7, 1, 46); word groupAddressOutput47 = G_ADDR(7, 1, 47); word groupAddressOutput48 = G_ADDR(7, 1, 48); word groupAddressOutput49 = G_ADDR(7, 1, 49); word groupAddressOutput50 = G_ADDR(7, 1, 50); word groupAddressOutput51 = G_ADDR(7, 1, 51); word groupAddressOutput52 = G_ADDR(7, 1, 52); word groupAddressOutput53 = G_ADDR(7, 1, 53); word groupAddressOutput54 = G_ADDR(7, 1, 54); word groupAddressOutput55 = G_ADDR(7, 1, 55); word groupAddressOutput56 = G_ADDR(7, 1, 56); // ################################################ // ### DEBUG Configuration // ################################################ //#define KDEBUG // comment this line to disable DEBUG mode #ifdef KDEBUG #include <DebugUtil.h> #endif // Define KONNEKTING Device related IDs #define MANUFACTURER_ID 57005 #define DEVICE_ID 255 #define REVISION 0 KnxComObject KnxDevice::_comObjectsList[] = { /* Suite-Index 0 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 1 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 2 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 3 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 4 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 5 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 6 : */ KnxComObject(KNX_DPT_5_001, COM_OBJ_SENSOR), /* Suite-Index 7 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 8 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 9 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 10 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 11 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 12 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 13 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 14 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 15 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 16 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 17 : */ KnxComObject(KNX_DPT_9_001, COM_OBJ_SENSOR), /* Suite-Index 18 : */ KnxComObject(KNX_DPT_1_002, COM_OBJ_SENSOR), /* Suite-Index 19 : */ KnxComObject(KNX_DPT_1_002, COM_OBJ_SENSOR), /* Suite-Index 20 : */ KnxComObject(KNX_DPT_1_002, COM_OBJ_SENSOR), /* Suite-Index 21 : */ KnxComObject(KNX_DPT_1_002, COM_OBJ_SENSOR), /* Suite-Index 22 : */ KnxComObject(KNX_DPT_1_002, COM_OBJ_SENSOR), /* Suite-Index 23 : */ KnxComObject(KNX_DPT_1_002, COM_OBJ_SENSOR), /* Suite-Index 24 : */ KnxComObject(KNX_DPT_1_002, COM_OBJ_SENSOR), /* Suite-Index 25 : */ KnxComObject(KNX_DPT_1_002, COM_OBJ_SENSOR), /* Suite-Index 26 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 27 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 28 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 29 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 30 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 31 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 32 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 33 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 34 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 35 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 36 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 37 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 38 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 39 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 40 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 41 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 42 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 43 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 44 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 45 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 46 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 47 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 48 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 49 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 50 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 51 : */ KnxComObject(KNX_DPT_9_000, COM_OBJ_SENSOR), /* Suite-Index 52 : */ KnxComObject(KNX_DPT_1_002, COM_OBJ_SENSOR), /* Suite-Index 53 : */ KnxComObject(KNX_DPT_1_002, COM_OBJ_SENSOR), /* Suite-Index 54 : */ KnxComObject(KNX_DPT_1_002, COM_OBJ_SENSOR), /* Suite-Index 55 : */ KnxComObject(KNX_DPT_1_002, COM_OBJ_SENSOR), /* Suite-Index 56 : */ KnxComObject(KNX_DPT_1_002, COM_OBJ_SENSOR), }; const byte KnxDevice::_numberOfComObjects = sizeof (_comObjectsList) / sizeof (KnxComObject); // do no change this code // Definition of parameter size byte KonnektingDevice::_paramSizeList[] = { /* Param Index 0 */ PARAM_UINT16 }; const int KonnektingDevice::_numberOfParams = sizeof (_paramSizeList); // do no change this code //we do not need a ProgLED, but this function muss be defined void progLed (bool state){ //nothing to do here Debug.println(F("Toggle ProgLED, actual state: %d"),state); } unsigned long sendDelay = 2000; unsigned long lastmillis = millis(); bool lastState = false; bool lastLedState = false; byte virtualEEPROM[16]; // ################################################ // ### KNX EVENT CALLBACK // ################################################ void knxEvents(byte index) { switch (index) { //case 0: // object index has been updated //Debug.println(F("ComObject 0 received: %d, let's trigger LED state"), Knx.read(0)); //lastLedState = !lastLedState; //digitalWrite(TEST_LED,lastLedState); // break; default: break; } } byte readMemory(int index){ return virtualEEPROM[index]; } void writeMemory(int index, byte val) { virtualEEPROM[index] = val; } void updateMemory(int index, byte val) { if (readMemory(index) != val) { writeMemory(index, val); } } void commitMemory() { } int readtoggle = 0; const uint16_t SystemRegsRead[NUM_SYSTEMREGS] = { REGO637_GT1_TGT_VALUE, //0 REGO637_GT1_ON_VALUE, //1 REGO637_GT1_OFF_VALUE, //2 REGO637_GT3_ON_VALUE, //3 REGO637_GT3_OFF_VALUE, //4 REGO637_GT4_TGT_VALUE, //5 REGO637_ADD_HEAT_PCT, //6 REGO637_REG_RADRTN, //7 REGO637_REG_OUTDOOR, //8 REGO637_REG_HOTWATER, //9 REGO637_REG_FORWARD, //10 REGO637_REG_ROOM, //11 REGO637_REG_COMPRESSOR, //12 REGO637_REG_HEAT_FLUID_OUT, //13 REGO637_REG_HEAT_FLUID_IN, //14 REGO637_REG_COLD_FLUID_OUT, //15 REGO637_REG_COLD_FLUID_IN, //16 REGO637_REG_EXTRN_HOT_WATER, //17 REGO637_REG_GND_LOOP_PMP, //18 REGO637_REG_COMPR_ST, //19 REGO637_ADDNL_HT_3KW, //20 REGO637_ADDNL_HT_6KW, //21 REGO637_RADIATOR_PUMP, //22 REGO637_HEAT_CARRIER_PUMP, //23 REGO637_THREEWAY_VALVE, //24 REGO637_ALARM, //25 REGO637_SETTINGS_HEAT_CURVE, //26 REGO637_SETTINGS_HEAT_CURVE_FINE_ADJ, //27 REGO637_SETTINGS_HEAT_CURVE_COUPL_DIFF, //28 REGO637_SETTINGS_HEAT_CURVE_TWO, //29 REGO637_SETTINGS_HEAT_CURVE_TW_FINE_ADJ, //30 REGO637_SETTINGS_ADJ_CURVE_20, //31 REGO637_SETTINGS_ADJ_CURVE_15, //32 REGO637_SETTINGS_ADJ_CURVE_10, //33 REGO637_SETTINGS_ADJ_CURVE_5, //34 REGO637_SETTINGS_ADJ_CURVE_0, //35 REGO637_SETTINGS_ADJ_CURVE_MINUS_5, //36 REGO637_SETTINGS_ADJ_CURVE_MINUS_10, //37 REGO637_SETTINGS_ADJ_CURVE_MINUS_15, //38 REGO637_SETTINGS_ADJ_CURVE_MINUS_20, //39 REGO637_SETTINGS_ADJ_CURVE_MINUS_25, //40 REGO637_SETTINGS_ADJ_CURVE_MINUS_30, //41 REGO637_SETTINGS_ADJ_CURVE_MINUS_35, //42 REGO637_SETTINGS_INDOOR_TEMP_SETTING, //43 REGO637_SETTINGS_CURVE_INF_BY_INTEMP, //44 REGO637_SETTINGS_SUMMER_DISCONNECTION, //45 REGO637_SETTINGS_HOT_WATER_TARGET, //46 REGO637_SETTINGS_HOT_WATER_HYSTERESIS, //47 REGO637_OH_RAD, //48 REGO637_OH_DHW, //49 REGO637_OH_ADDHEAT_RAD, //50 REGO637_OH_ADDHEAT_DHW //51 }; const char *SystemRegsNames[NUM_SYSTEMREGS] = { "GT1 Target value...:", //1 temp "GT1 ON value.......:", //2 temp "GT1 OFF value......:", //3 temp "GT3 ON value.......:", //4 temp "GT3 OFF value......:", //5 temp "GT4 Target Value...:", //6 temp "ADD HEAT PCT.......:", //7 percent "Radiator Return....: ", //8 temp "Outdoor............: ", //9 temp "Hot water..........: ", //10 temp "Forward............: ", //11 temp "Room...............: ", //12 temp "Compressor.........: ", //13 temp "Heat fluid out.....: ", //14 temp "Heat fluid in......: ", //15 temp "Cold fluid out.....: ", //16 temp "Cold fluid in......: ", //17 temp "External hot water.: ", //18 temp "Ground loop pump...: ", //19 BOOL "Compressor on/off..: ", //20 BOOL "Additional 3Kw.....: ", //21 BOOL "Additional 6Kw.....: ", //22 BOOL "Radiator pump [P1].: ", //23 BOOL "Heat Carrier pump [P2].:", //24 BOOL "3-way valve on/off.:", //25 BOOL "Alarm..............:", //26 BOOL "Heat curve...................:", //27 TEMP "Heat Curve fine adj..........:", //28 TEMP "Heat curve coupl. diff.......:", //29 TEMP "Heat curve two...............:", //30 TEMP "Heat curve two fine adj......:", //31 TEMP "Adjustment curve at 20.......:", //32 TEMP "Adjustment curve at 15.......:", //33 TEMP "Adjustment curve at 10.......:", //34 TEMP "Adjustment curve at 5........:", //35 TEMP "Adjustment curve at 0........:", //36 TEMP "Adjustment curve at min 5....:", //37 TEMP "Adjustment curve at min 10...:", //38 TEMP "Adjustment curve at min 15...:", //39 TEMP "Adjustment curve at min 20...:", //40 TEMP "Adjustment curve at min 25...:", //41 TEMP "Adjustment curve at min 30...:", //42 TEMP "Adjustment curve at min 35...:", //43 TEMP "Indoor temp setting..........:", //44 TEMP "Curve infl. by intemp........:", //45 TEMP "Summer Disconnection.........:", //46 TEMP "Hot water setpoint value.....:", //47 TEMP "Hot water hysteresis.........:", //48 TEMP "Oper.hours RAD...............:", "Oper.hours DHW...............:", "Oper.hours add heat RAD......:", "Oper.hours add heat DHW......:" }; const int SystemRegsKNX[NUM_SYSTEMREGS] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, }; const uint16_t FrntPnlRead[NUM_FRONTPANEL] = { REGO637_FRNTPNL_LED_POWER, //52 REGO637_FRNTPNL_LED_PUMP, //53 REGO637_FRNTPNL_LED_ADD_HEAT, //54 REGO637_FRNTPNL_LED_BOILER, //55 REGO637_FRNTPNL_ALARM //56 }; const char *FrntPnlNames[NUM_FRONTPANEL] = { "LED Power.....................:", //bool "LED Heat pump.................:", //bool "LED Add heat..................:", //bool "LED Boiler....................:", //bool "LED Alarm.....................:", //bool }; const int FrntPnlKNX[NUM_FRONTPANEL] = { 52, //bool 53, //bool 54, //bool 55, //bool 56, //bool }; Uart Serial2 (&sercom1, 11, 10, SERCOM_RX_PAD_0, UART_TX_PAD_2); void SERCOM1_Handler() { Serial2.IrqHandler(); } //heatpump is on Serial2 Rego637 Heatpump( Serial2 ); byte nSystemRegs; byte nFrontPanel; void setup( void ) { memset(virtualEEPROM,0xFF,16); Konnekting.setMemoryReadFunc(&readMemory); Konnekting.setMemoryWriteFunc(&writeMemory); Konnekting.setMemoryUpdateFunc(&updateMemory); Konnekting.setMemoryCommitFunc(&commitMemory); // simulating allready programmed Konnekting device: // in this case we don't need Konnekting Suite // write hardcoded PA and GAs writeMemory(0, 0x7F); //Set "not factory" flag writeMemory(1, (byte)(individualAddress >> 8)); writeMemory(2, (byte)(individualAddress)); writeMemory(10, (byte)(groupAddressOutput0 >> 8)); writeMemory(11, (byte)(groupAddressOutput0)); writeMemory(12, 0x80); //activate InputGA writeMemory(13, (byte)(groupAddressOutput1 >> 8)); writeMemory(14, (byte)(groupAddressOutput1)); writeMemory(15, 0x80); //activate InputGA writeMemory(16, (byte)(groupAddressOutput2 >> 8)); writeMemory(17, (byte)(groupAddressOutput2)); writeMemory(18, 0x80); //activate InputGA writeMemory(19, (byte)(groupAddressOutput3 >> 8)); writeMemory(20, (byte)(groupAddressOutput3)); writeMemory(21, 0x80); //activate InputGA writeMemory(22, (byte)(groupAddressOutput4 >> 8)); writeMemory(23, (byte)(groupAddressOutput4)); writeMemory(24, 0x80); //activate InputGA writeMemory(25, (byte)(groupAddressOutput5 >> 8)); writeMemory(26, (byte)(groupAddressOutput5)); writeMemory(27, 0x80); //activate InputGA writeMemory(28, (byte)(groupAddressOutput6 >> 8)); writeMemory(29, (byte)(groupAddressOutput6)); writeMemory(30, 0x80); //activate InputGA writeMemory(31, (byte)(groupAddressOutput7 >> 8)); writeMemory(32, (byte)(groupAddressOutput7)); writeMemory(33, 0x80); //activate InputGA writeMemory(34, (byte)(groupAddressOutput8 >> 8)); writeMemory(35, (byte)(groupAddressOutput8)); writeMemory(36, 0x80); //activate InputGA writeMemory(37, (byte)(groupAddressOutput9 >> 8)); writeMemory(38, (byte)(groupAddressOutput9)); writeMemory(39, 0x80); //activate InputGA writeMemory(40, (byte)(groupAddressOutput10 >> 8)); writeMemory(41, (byte)(groupAddressOutput10)); writeMemory(42, 0x80); //activate InputGA writeMemory(43, (byte)(groupAddressOutput11 >> 8)); writeMemory(44, (byte)(groupAddressOutput11)); writeMemory(45, 0x80); //activate InputGA writeMemory(46, (byte)(groupAddressOutput12 >> 8)); writeMemory(47, (byte)(groupAddressOutput12)); writeMemory(48, 0x80); //activate InputGA writeMemory(49, (byte)(groupAddressOutput13 >> 8)); writeMemory(50, (byte)(groupAddressOutput13)); writeMemory(51, 0x80); //activate InputGA writeMemory(52, (byte)(groupAddressOutput14 >> 8)); writeMemory(53, (byte)(groupAddressOutput14)); writeMemory(54, 0x80); //activate InputGA writeMemory(55, (byte)(groupAddressOutput15 >> 8)); writeMemory(56, (byte)(groupAddressOutput15)); writeMemory(57, 0x80); //activate InputGA writeMemory(58, (byte)(groupAddressOutput16 >> 8)); writeMemory(59, (byte)(groupAddressOutput16)); writeMemory(60, 0x80); //activate InputGA writeMemory(61, (byte)(groupAddressOutput17 >> 8)); writeMemory(62, (byte)(groupAddressOutput17)); writeMemory(63, 0x80); //activate InputGA writeMemory(64, (byte)(groupAddressOutput18 >> 8)); writeMemory(65, (byte)(groupAddressOutput18)); writeMemory(66, 0x80); //activate InputGA writeMemory(67, (byte)(groupAddressOutput19 >> 8)); writeMemory(68, (byte)(groupAddressOutput19)); writeMemory(69, 0x80); //activate InputGA writeMemory(70, (byte)(groupAddressOutput20 >> 8)); writeMemory(71, (byte)(groupAddressOutput20)); writeMemory(72, 0x80); //activate InputGA writeMemory(73, (byte)(groupAddressOutput21 >> 8)); writeMemory(74, (byte)(groupAddressOutput21)); writeMemory(75, 0x80); //activate InputGA writeMemory(76, (byte)(groupAddressOutput22 >> 8)); writeMemory(77, (byte)(groupAddressOutput22)); writeMemory(78, 0x80); //activate InputGA writeMemory(79, (byte)(groupAddressOutput23 >> 8)); writeMemory(80, (byte)(groupAddressOutput23)); writeMemory(81, 0x80); //activate InputGA writeMemory(82, (byte)(groupAddressOutput24 >> 8)); writeMemory(83, (byte)(groupAddressOutput24)); writeMemory(84, 0x80); //activate InputGA writeMemory(85, (byte)(groupAddressOutput25 >> 8)); writeMemory(86, (byte)(groupAddressOutput25)); writeMemory(87, 0x80); //activate InputGA writeMemory(88, (byte)(groupAddressOutput26 >> 8)); writeMemory(89, (byte)(groupAddressOutput26)); writeMemory(90, 0x80); //activate InputGA writeMemory(91, (byte)(groupAddressOutput27 >> 8)); writeMemory(92, (byte)(groupAddressOutput27)); writeMemory(93, 0x80); //activate InputGA writeMemory(94, (byte)(groupAddressOutput28 >> 8)); writeMemory(95, (byte)(groupAddressOutput28)); writeMemory(96, 0x80); //activate InputGA writeMemory(97, (byte)(groupAddressOutput29 >> 8)); writeMemory(98, (byte)(groupAddressOutput29)); writeMemory(99, 0x80); //activate InputGA writeMemory(100, (byte)(groupAddressOutput30 >> 8)); writeMemory(101, (byte)(groupAddressOutput30)); writeMemory(102, 0x80); //activate InputGA writeMemory(103, (byte)(groupAddressOutput31 >> 8)); writeMemory(104, (byte)(groupAddressOutput31)); writeMemory(105, 0x80); //activate InputGA writeMemory(106, (byte)(groupAddressOutput32 >> 8)); writeMemory(107, (byte)(groupAddressOutput32)); writeMemory(108, 0x80); //activate InputGA writeMemory(109, (byte)(groupAddressOutput33 >> 8)); writeMemory(110, (byte)(groupAddressOutput33)); writeMemory(111, 0x80); //activate InputGA writeMemory(112, (byte)(groupAddressOutput34 >> 8)); writeMemory(113, (byte)(groupAddressOutput34)); writeMemory(114, 0x80); //activate InputGA writeMemory(115, (byte)(groupAddressOutput35 >> 8)); writeMemory(116, (byte)(groupAddressOutput35)); writeMemory(117, 0x80); //activate InputGA writeMemory(118, (byte)(groupAddressOutput36 >> 8)); writeMemory(119, (byte)(groupAddressOutput36)); writeMemory(120, 0x80); //activate InputGA writeMemory(121, (byte)(groupAddressOutput37 >> 8)); writeMemory(122, (byte)(groupAddressOutput37)); writeMemory(123, 0x80); //activate InputGA7 writeMemory(124, (byte)(groupAddressOutput38 >> 8)); writeMemory(125, (byte)(groupAddressOutput38)); writeMemory(126, 0x80); //activate InputGA writeMemory(127, (byte)(groupAddressOutput39 >> 8)); writeMemory(128, (byte)(groupAddressOutput39)); writeMemory(129, 0x80); //activate InputGA writeMemory(130, (byte)(groupAddressOutput40 >> 8)); writeMemory(131, (byte)(groupAddressOutput40)); writeMemory(132, 0x80); //activate InputGA writeMemory(133, (byte)(groupAddressOutput41 >> 8)); writeMemory(134, (byte)(groupAddressOutput41)); writeMemory(135, 0x80); //activate InputGA writeMemory(136, (byte)(groupAddressOutput42 >> 8)); writeMemory(137, (byte)(groupAddressOutput42)); writeMemory(138, 0x80); //activate InputGA writeMemory(139, (byte)(groupAddressOutput43 >> 8)); writeMemory(140, (byte)(groupAddressOutput43)); writeMemory(141, 0x80); //activate InputGA writeMemory(142, (byte)(groupAddressOutput44 >> 8)); writeMemory(143, (byte)(groupAddressOutput44)); writeMemory(144, 0x80); //activate InputGA writeMemory(145, (byte)(groupAddressOutput45 >> 8)); writeMemory(146, (byte)(groupAddressOutput45)); writeMemory(147, 0x80); //activate InputGA writeMemory(148, (byte)(groupAddressOutput46 >> 8)); writeMemory(149, (byte)(groupAddressOutput46)); writeMemory(150, 0x80); //activate InputGA writeMemory(151, (byte)(groupAddressOutput47 >> 8)); writeMemory(152, (byte)(groupAddressOutput47)); writeMemory(153, 0x80); //activate InputGA writeMemory(154, (byte)(groupAddressOutput48 >> 8)); writeMemory(155, (byte)(groupAddressOutput48)); writeMemory(156, 0x80); //activate InputGA writeMemory(157, (byte)(groupAddressOutput49 >> 8)); writeMemory(158, (byte)(groupAddressOutput49)); writeMemory(159, 0x80); //activate InputGA writeMemory(160, (byte)(groupAddressOutput50 >> 8)); writeMemory(161, (byte)(groupAddressOutput50)); writeMemory(162, 0x80); //activate InputGA writeMemory(163, (byte)(groupAddressOutput51 >> 8)); writeMemory(164, (byte)(groupAddressOutput51)); writeMemory(165, 0x80); //activate InputGA writeMemory(166, (byte)(groupAddressOutput52 >> 8)); writeMemory(167, (byte)(groupAddressOutput52)); writeMemory(168, 0x80); //activate InputGA writeMemory(169, (byte)(groupAddressOutput53 >> 8)); writeMemory(170, (byte)(groupAddressOutput53)); writeMemory(171, 0x80); //activate InputGA writeMemory(172, (byte)(groupAddressOutput54 >> 8)); writeMemory(173, (byte)(groupAddressOutput54)); writeMemory(174, 0x80); //activate InputGA writeMemory(175, (byte)(groupAddressOutput55 >> 8)); writeMemory(176, (byte)(groupAddressOutput55)); writeMemory(177, 0x80); //activate InputGA writeMemory(178, (byte)(groupAddressOutput56 >> 8)); writeMemory(179, (byte)(groupAddressOutput56)); writeMemory(180, 0x80); //activate InputGA // debug related stuff #ifdef KDEBUG // Start debug serial with 115200 bauds DEBUGSERIAL.begin(115200); //waiting 3 seconds, so you have enough time to start serial monitor delay(3000); // make debug serial port known to debug class // Means: KONNEKTING will use the same serial port for console debugging Debug.setPrintStream(&DEBUGSERIAL); #endif // Initialize KNX enabled Arduino Board Konnekting.init(KNX_SERIAL, &progLed, MANUFACTURER_ID, DEVICE_ID, REVISION); pinMode(TEST_LED,OUTPUT); Debug.println(F("Toggle LED every %d ms."), sendDelay); Debug.println(F("Setup is ready. Turning LED on and going to loop...")); SerialUSB.begin( 19200 ); //serial monitor while(!SerialUSB); SerialUSB.println("Setup complete"); Heatpump.start( 19200 ); //Rego637 heatpump pinPeripheral(10, PIO_SERCOM); pinPeripheral(11, PIO_SERCOM); nSystemRegs = 0; nFrontPanel = 0; }//setup void loop( void ) { SerialUSB.println("Inside loop"); Knx.task(); static unsigned long timeReadRegister = 0; // if the heatpump logic is ready, send a request for sensor data if( millis() - timeReadRegister > 1000 ) { timeReadRegister = millis(); if( readtoggle == 0) { if( Heatpump.GetMsgStatus() == MSG_IDLE ) Heatpump.ReadSystemRegisters( SystemRegsRead[nSystemRegs] ); } else if ( readtoggle == 1) { if( Heatpump.GetMsgStatus() == MSG_IDLE ) Heatpump.ReadFrontPanelRegisters( FrntPnlRead[nFrontPanel] ); } }//if if( readtoggle == 0) { CheckSystemRegsReadMessage(); } else if(readtoggle == 1) { CheckFrontPanelReadMessage(); } }//loop void CheckSystemRegsReadMessage( void ) { uint8_t chkRtn; int16_t sysregval; //while spinning in main, keep an eye out for a message chkRtn = Heatpump.CheckSysRegMessage( &sysregval ); switch( chkRtn ) { case MSG_COMPLETE: if (Konnekting.isReadyForApplication()) { //message is complete; print what was received Heatpump.ClrMsgStatus(); SerialUSB.print( SystemRegsNames[nSystemRegs] ); if( (nSystemRegs >= 1) && (nSystemRegs <= 6)) { SerialUSB.print( (float)sysregval/10.0, 1 ); SerialUSB.println( " C" ); SerialUSB.println(SystemRegsKNX[nSystemRegs]); Knx.write(SystemRegsKNX[nSystemRegs], (float)sysregval/10.0); } else if( (nSystemRegs >= 8) && (nSystemRegs <= 18)) { SerialUSB.print( (float)sysregval/10.0, 1 ); SerialUSB.println( " C" ); SerialUSB.println(SystemRegsKNX[nSystemRegs]); Knx.write(SystemRegsKNX[nSystemRegs], (float)sysregval/10.0); } else if( (nSystemRegs >= 27) && (nSystemRegs <= 48)) { SerialUSB.print( (float)sysregval/10.0, 1 ); SerialUSB.println( " C" ); SerialUSB.println(SystemRegsKNX[nSystemRegs]); Knx.write(SystemRegsKNX[nSystemRegs], (float)sysregval/10.0); } else { SerialUSB.println( sysregval ); SerialUSB.println(SystemRegsKNX[nSystemRegs]); Knx.write(SystemRegsKNX[nSystemRegs], sysregval); } nSystemRegs++; if( nSystemRegs == NUM_SYSTEMREGS ) { readtoggle = 1; nSystemRegs = 0; } } break; case MSG_IDLE: case MSG_WAITING: //do nothing if just waiting or in idle state... break; default: //something else is going on; print verbose message of what the problem is //print a message to the monitor identifying the error SerialUSB.print( "Message error.....: " ); SerialUSB.println( RegoErrorMsgs[chkRtn] ); break; }//switch }//CheckSensorMessage void CheckFrontPanelReadMessage( void ) { uint8_t chkRtn; int16_t frntpnlval; //while spinning in main, keep an eye out for a message chkRtn = Heatpump.CheckFrontPanelMessage( &frntpnlval ); switch( chkRtn ) { case MSG_COMPLETE: if (Konnekting.isReadyForApplication()) { //message is complete; print what was received Heatpump.ClrMsgStatus(); SerialUSB.print( FrntPnlNames[nFrontPanel] ); SerialUSB.println( frntpnlval); //<-- change to display oC Knx.write(FrntPnlKNX[nSystemRegs], frntpnlval); nFrontPanel++; if( nFrontPanel == NUM_FRONTPANEL ) { readtoggle = 0; nFrontPanel = 0; } } break; case MSG_IDLE: case MSG_WAITING: //do nothing if just waiting or in idle state... break; default: //something else is going on; print verbose message of what the problem is //print a message to the monitor identifying the error SerialUSB.print( "Message error.....: " ); SerialUSB.println( RegoErrorMsgs[chkRtn] ); break; }//switch }//CheckSensorMessage
Kommentar