Permalink
Browse files

set boardtyp hinzugefuegt

  • Loading branch information...
ingo ingo
ingo authored and ingo committed Jan 5, 2018
1 parent 88b86ab commit 82194073af54b89d5cc11c803cc75b5f8ec9a856
Showing with 47 additions and 32 deletions.
  1. +34 −9 libhcan++/board_driver.cc
  2. +1 −0 libhcan++/board_driver.h
  3. +9 −23 libhcan++/driver_factory.cc
  4. +3 −0 libhcan++/driver_factory.h
View
@@ -45,6 +45,7 @@ bool board_driver::show_help ()
" dump ee <address> dumps a eeprom range\n" <<
" set ee <address> <value> save value to eeprom\n" <<
" set address <hcan-address> save a new hcan address\n" <<
" set boardtyp <hcan-boardtyp> save a new hcan boardtyp [3=C1416|4=C1612|5=UI]\n" <<
" set sysloglevel <level> set the syslog level\n" <<
" bootloader boot into bootloader\n" <<
" loadapp load the application\n" <<
@@ -173,11 +174,18 @@ bool board_driver::exec_command (context &c, const string &command)
return true;
}
if (s == "boardtyp")
{
uint16_t value;
sin >> value;
cmd_setboardtyp(value);
return true;
}
if (s == "sysloglevel")
{
uint16_t level;
sin >> level;
cmd_setsysloglevel(level);
return true;
}
@@ -580,6 +588,24 @@ void board_driver::cmd_setaddress (const uint16_t address)
cerr << "error: value written to eeprom does not match read";
}
void board_driver::cmd_setboardtyp (const uint16_t boardtyp)
{
if ( HCAN_BOARDTYP_HI == boardtyp
|| HCAN_BOARDTYP_C1416 == boardtyp
|| HCAN_BOARDTYP_C1612 == boardtyp
|| HCAN_BOARDTYP_UI == boardtyp
|| HCAN_BOARDTYP_USV == boardtyp
|| HCAN_BOARDTYP_ZENTRALHEIZUNG == boardtyp
|| HCAN_BOARDTYP_WETTERSTATION == boardtyp)
{
write_eeprom_word_le(4, boardtyp);
if (read_eeprom_word_le(4) != boardtyp)
cerr << "error: boardtyp-value written to eeprom does not match read";
}
else
cerr << "error: boardtyp=" << boardtyp << " unkown!";
}
void board_driver::cmd_setsysloglevel(uint16_t level)
{
@@ -654,14 +680,13 @@ void board_driver::cmd_show_system()
cout << "Board : ";
switch (type)
{
case 1 : cout << "Versuchsboard1 v02"; break;
case 2 : cout << "Host-Interface v01, serial"; break;
case 3 : cout << "Controllerboard-88 v01"; break;
case 4 : cout << "Controllerboard-1612 v01"; break;
case 5 : cout << "Userpanel-v01"; break;
case 6 : cout << "USV Controller"; break;
case 7 : cout << "Heizungssteuerung"; break;
case 8 : cout << "Wetterstation"; break;
case HCAN_BOARDTYP_HI : cout << "Host-Interface v01, serial"; break;
case HCAN_BOARDTYP_C1416 : cout << "Controllerboard-1416"; break;
case HCAN_BOARDTYP_C1612 : cout << "Controllerboard-1612 v01"; break;
case HCAN_BOARDTYP_UI : cout << "Userpanel-v01"; break;
case HCAN_BOARDTYP_USV : cout << "USV Controller"; break;
case HCAN_BOARDTYP_ZENTRALHEIZUNG : cout << "Zentralheizungssteuerung"; break;
case HCAN_BOARDTYP_WETTERSTATION : cout << "Wetterstation"; break;
default : cout << "unknown";
}
cout << endl << "MCU : ";
View
@@ -55,6 +55,7 @@ namespace hcan
virtual void cmd_flash (const string &filename);
virtual uint16_t cmd_getaddress ();
virtual void cmd_setaddress (const uint16_t address);
virtual void cmd_setboardtyp (const uint16_t boardtyp);
virtual void cmd_reset();
virtual uint32_t cmd_getuptime();
virtual uint8_t cmd_getstate();
@@ -24,15 +24,15 @@ board_driver_p driver_factory::make_driver (board_connection &bcon,
case HCAN_ARCH_ATMEGA32 :
switch (type)
{
case 4 : // Controllerboard-1612 v01
case HCAN_BOARDTYP_C1612 : // Controllerboard-1612 v01
return board_driver_p(new controllerboard_driver(bcon));
case 5 : // Userpanel v01
case HCAN_BOARDTYP_UI : // Userpanel v01
return board_driver_p(new userpanel_driver(bcon));
case 6 : // USV Controller1612-Module
case HCAN_BOARDTYP_USV : // USV Controller1612-Module
return board_driver_p(new usv_driver(bcon));
case 7 : // Heizungssteuerung Controllerboard-1612 v01
case HCAN_BOARDTYP_ZENTRALHEIZUNG : // Heizungssteuerung Controllerboard-1612 v01
return board_driver_p(new controllerboard_driver(bcon));
case 8 : // Wetterstation Controllerboard-1612 v01
case HCAN_BOARDTYP_WETTERSTATION : // Wetterstation Controllerboard-1612 v01
return board_driver_p(new controllerboard_driver(bcon));
default :
cerr << "warning: unknown board type id " << int(type)
@@ -44,16 +44,10 @@ board_driver_p driver_factory::make_driver (board_connection &bcon,
page_size = 256;
switch (type)
{
case 4 : // Controllerboard-1612 v01
case HCAN_BOARDTYP_C1612 : // Controllerboard-1612 v01
return board_driver_p(new controllerboard_driver(bcon, page_size));
case 5 : // Userpanel v01
case HCAN_BOARDTYP_UI : // Userpanel v01
return board_driver_p(new userpanel_driver(bcon, page_size));
case 6 : // USV Controller1612-Module
return board_driver_p(new usv_driver(bcon, page_size));
case 7 : // Heizungssteuerung Controllerboard-1612 v01
return board_driver_p(new controllerboard_driver(bcon, page_size));
case 8 : // Wetterstation Controllerboard-1612 v01
return board_driver_p(new controllerboard_driver(bcon, page_size));
default :
cerr << "warning: unknown board type id " << int(type)
<< ", using generic atmega644p driver..." << endl;
@@ -63,16 +57,8 @@ board_driver_p driver_factory::make_driver (board_connection &bcon,
case HCAN_ARCH_ATMEGA328P :
switch (type)
{
case 4 : // Controllerboard-1612 v01
return board_driver_p(new controllerboard_driver(bcon));
case 5 : // Userpanel v01
return board_driver_p(new userpanel_driver(bcon));
case 6 : // USV Controller1612-Module
return board_driver_p(new usv_driver(bcon));
case 7 : // Heizungssteuerung Controllerboard-1612 v01
return board_driver_p(new controllerboard_driver(bcon));
case 8 : // Wetterstation Controllerboard-1612 v01
return board_driver_p(new controllerboard_driver(bcon));
case HCAN_BOARDTYP_C1416 :
return board_driver_p(new controllerboard_driver(bcon, page_size));
default :
cerr << "warning: unknown board type id " << int(type)
<< ", using generic atmega328p driver..." << endl;
@@ -19,6 +19,9 @@ namespace hcan
enum { HCAN_ARCH_ATMEGA32 = 0x01, HCAN_ARCH_ATMEGA644P = 0x02, HCAN_ARCH_ATMEGA328P = 0x33, HCAN_ARCH_AUTODETECT = 255 };
enum { HCAN_BOARDTYP_HI = 2, HCAN_BOARDTYP_C1416 = 3, HCAN_BOARDTYP_C1612 = 4, HCAN_BOARDTYP_UI = 5,
HCAN_BOARDTYP_USV = 6, HCAN_BOARDTYP_ZENTRALHEIZUNG = 7, HCAN_BOARDTYP_WETTERSTATION = 8};
class driver_factory
{
private:

0 comments on commit 8219407

Please sign in to comment.