Permalink
Browse files

Erweiterungen von hcanMartin

  • Loading branch information...
il il
il authored and il committed Aug 27, 2018
1 parent 455516d commit ea06981993bebcb2a10943933f5ffe3eb2107c9d
@@ -28,3 +28,7 @@ export MCU = atmega644p
###########################
export IP_HI = 192.168.1.42
###########################
# z.B. -DhcanXYZ
export GLOBAL_DEFINES =
###########################
@@ -373,12 +373,7 @@ uint8_t canix_init(void)
for (i = 0; i < MAX_RTC_CALLBACKS; i++)
rtc_callback[i] = (canix_rtc_callback) 0;
#ifdef CANIX_LED_SETUP1
canix_led_init_ports();
#endif
#ifdef CANIX_LED_SETUP2
canix_led_init_ports();
#endif
// Eingangsbuffer leeren
for (i = 0; i < CANIX_QUEUE_SIZE; i++)
@@ -21,29 +21,20 @@
#ifndef CANIX_LED_H
#define CANIX_LED_H
#ifdef CANIX_LED_SETUP1
#if defined(__AVR_ATmega32__)
#define CANIX_LED_YELLOW 1
#define CANIX_LED_RED 2
#define LED_PORT PORTB
#define LED_PORT_DDR DDRB
#endif
#ifdef CANIX_LED_SETUP2
#define CANIX_LED_YELLOW 2
#define CANIX_LED_RED 1
#define LED_PORT PORTB
#define LED_PORT_DDR DDRB
#endif
#ifdef CANIX_LED_SETUP3
#define CANIX_LED_YELLOW 2
#define CANIX_LED_RED 1
#define LED_PORT PORTA
#define LED_PORT_DDR DDRA
#if defined(__AVR_ATmega328P__)
#define CANIX_LED_YELLOW 1
#define CANIX_LED_RED 0
#define LED_PORT PORTD
#define LED_PORT_DDR DDRD
#endif
#ifdef CANIX_NO_LED_SETUP
#define canix_led_enable(LED)
@@ -54,6 +45,7 @@
#define canix_led_enable(LED) { LED_PORT &= ~ (1<< LED); }
#define canix_led_disable(LED) { LED_PORT |= 1<< LED; }
#define canix_led_toggle(LED) { LED_PORT ^= (1<< LED); }
#define canix_led_init_ports() \
{ \
LED_PORT_DDR |= (1<< CANIX_LED_RED) | (1<< CANIX_LED_YELLOW); \
@@ -14,6 +14,12 @@ void darlingtonoutput_init(void)
// Darlington Ports ausschalten
PORTD = 0;
PORTB &= ~ (0x0f);
#elif defined (__AVR_ATmega328P__) && defined (hcanMartin)
// Darlington Ports auf Output setzen
DDRD |= (1 << DDD7) | (1 << DDD6) | (1 << DDD5) | (1 << DDD4) | (1 << DDD3) | (1 << DDD2);
// Darlington Ports ausschalten
PORTD &= ~( (1 << PORTD7) | (1 << PORTD6) | (1 << PORTD5) | (1 << PORTD4) | (1 << PORTD3) | (1 << PORTD2) );
#endif
}
@@ -29,6 +35,11 @@ uint8_t darlingtonoutput_getpin(uint8_t n)
n = n - 8;
return PORTB & (1<< n);
}
#elif defined (__AVR_ATmega328P__) && defined (hcanMartin)
if (n >= 2 && n <= 7)
{
return PORTD & (1<< n);
}
#endif
return ports_getOutput(n);
}
@@ -51,6 +51,7 @@ void devices_load_config(void)
devices_init();
eds_block_p it;
unknown_device_found = 0;
EDS_foreach_block_between(it,1,255)
{
@@ -74,6 +75,7 @@ void devices_load_config(void)
{
canix_syslog_P(SYSLOG_PRIO_ERROR,
PSTR(&quot;EDS_BLOCK_TYPE unknown:%d EDS Addr:%d&quot;), EDS_BLOCK_TYPE(it), it);
unknown_device_found = 1;
}
continue;
@@ -30,6 +30,7 @@ extern uint8_t device_data_size[];
extern uint8_t *pdevice_data[];
extern uint8_t device_data[];
extern uint16_t device_data_ram_usage;
uint8_t unknown_device_found;
void devices_load_config(void);
void hauselektrik_callback(const canix_frame *frame);
@@ -142,6 +142,15 @@ void idle_handler(void)
}
}
if (unknown_device_found > 0) { // wenn ein unbekanntest Device gefunden wurde, ist die Variable 1
unknown_device_found++; // dann zaehlen wir die Sek. hoch ...
}
if(unknown_device_found == 10) { // ... und nach 10 Sek. kommt eine Syslogmeldung
canix_syslog_P(SYSLOG_PRIO_ERROR,
PSTR(&quot;unknown EDS_BLOCK_TYPE found. See Boot MSG&quot;));
unknown_device_found = 1; // und im naechsten Durchlauf wieder hochzaehlen bis 10 ...
}
/* vermutlich nicht ganz korrekt und per "EDS config RAM overflow" schon zum Teil abgedeckt:
unusedSRAM = get_mem_unused();
if( unusedSRAM &lt; MAX_MEM_CRITICAL_SIZE )
@@ -29,8 +29,7 @@
#include "../canix/mcp2515_defs.h"
#include "../canix/mcp2515_bl.h"
#define CANIX_NO_LED_SETUP
//#define CANIX_LED_SETUP2
//#define CANIX_NO_LED_SETUP
#include "../canix/led.h"
#include "../include/hcan_multicast.h"
@@ -17,7 +17,7 @@ namespace hcan
driver_error (const string &s);
};
enum { HCAN_ARCH_ATMEGA32 = 0x01, HCAN_ARCH_ATMEGA644P = 0x02, HCAN_ARCH_ATMEGA328P = 0x33, HCAN_ARCH_AUTODETECT = 255 };
enum { HCAN_ARCH_ATMEGA32 = 0x11, HCAN_ARCH_ATMEGA644P = 0x22, 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};
@@ -216,6 +216,46 @@ void transport_connection::flood_ping(uint16_t src, uint16_t dst,
}
}
void transport_connection::ping_once(uint16_t src, uint16_t dst)
{
cout << "sending one ping packet from " << src << " to "
<< dst << "..." << endl;
try
{
#ifndef __WIN32__
struct timeval starttv,endtv;
gettimeofday(&starttv,0);
#endif
send_PING_REQUEST(src,dst);
recv_PING_REPLAY(dst,src);
#ifndef __WIN32__
gettimeofday(&endtv,0);
uint64_t diff = (endtv.tv_sec * 1000000 + endtv.tv_usec) -
(starttv.tv_sec * 1000000 + starttv.tv_usec);
cout << " [" << (1) << "] " << (diff / 1000) << " msec";
#else
cout << " [" << (1) << "] ";
#endif
}
catch (const transport_error &e)
{
// we are pinging, so ignore possible timeouts
keep_connection_alive();
}
#ifndef __WIN32__
usleep (200000);
#else
_sleep(200);
#endif
cout << endl;
}
volatile bool done = false;
@@ -307,7 +347,10 @@ void transport_connection::syslog()
// yes, there is already something; now add the
// string received
it->second.msg += f.data_as_string();
if(f.data_as_string()[0] == it->second.prio)
it->second.msg += f.data_as_string().substr(1);
else
it->second.msg += f.data_as_string();
// now check it the string we have built is complete:
const string s = it->second.msg;
@@ -342,7 +385,7 @@ void transport_connection::syslog()
else
{
// no, it is the first packet
messages[f.src()].msg = f.data_as_string();
messages[f.src()].msg = f.data_as_string().substr(1);
messages[f.src()].prio = f.data_as_string()[0];
}
}
@@ -35,6 +35,7 @@ namespace hcan
virtual ~transport_connection() throw ();
void keep_connection_alive();
void ping(uint16_t src, uint16_t dst);
void ping_once(uint16_t src, uint16_t dst);
void flood_ping(uint16_t src, uint16_t dst, const int load);
void dump(bool numeric, bool color);
void templog();

0 comments on commit ea06981

Please sign in to comment.