Moin,
@Michael: Jawoll, mit der Änderung lüppt es. Die erzeugte control6.c ist
im Anhang. Ist das ein Bug, der geforkt wird ? Sonst passe ich wohl
einfach alle meine Boards an, wenn das nicht mit einem git pull origin
in die Quere kommt...
@Justin: Ich nutze das, um regelmäßig oder aufgrund eines Eregnisses die
Messwerte am ADC und die PINzustände an meinen Hausbus zu übertagen. Da
habe ich eine http-Schnittstelle, wo ich im Prinzip alles im Haus
steuern kann. Watch-IO wollte einfach nicht, wenn die PINS auf Output
stehen.
P.S. Mich wundert es, dass ich im Netz Beispiele mit HTTPLOG finde:
http://wiki.volkszaehler.org/hardware/channels/sensors/1_wire
da steht dann HTTPLOG("<uuid>.json?value=%s", temp_str);
also doch mehr als 1 Parameter, wenn printf-Formatierungen genutzt werden ?
Jedenfalls super, dass es jetzt funzt !
Grüße,
Tom
Am 11.05.2015 um 09:51 schrieb Michael Brakemeier:
Hi,
@Tom: ändere doch bitte mal in Zeile 16 in control6/lang.d/50_httplog.m4
das `httplog_P($1)' in `httplog($1)' und versuche es nochmal. Und poste
doch bitte mal die aus dem control6 generierte C-Quelle.
VG michaelb
P.S.: das ist m4-Code - die unterschiedlichen Hochkommata müssen genau
so ;-)
Am 11.05.2015 um 09:19 schrieb jus...@justinotherguy.org:
Hi Tom,
Am 11.05.2015 um 07:16 schrieb Tom Weber <tom.we...@gmx.de>:
wenn ich den request mit httplog aus control6 absetze, sehe ich in Wireshark:
GET /pck?\001 HTTP/1.1\n
dabei scheint es ziemlich egal zu sein, welchen String ich da absetze. So erzeugt ein
HTTPLOG("Kuckuck") in Wireshark:
GET /pck?\001 HTTP/1.1\n
aus purer Verzweiflung habe ich jetzt ein HTTPLOG("Kuckuck","test"); abgesetzt,
dann kommt:
GET /pck?Kuckuck HTTP/1.1\n
kann es sein, dass irgendwie eine 2.Option nötig ist?
das klingt seltsam; ich bin nicht sicher, ob ich httplog via control6 je selbst
verwendet habe.
Via watchasync und via ecmd klappt’s auf alle Fälle - mag sein, dass das in
control6 ne Macke hat.
Was genau hast Du denn vor?
Gruß, J.
_______________________________________________
Ethersex-devel mailing list
Ethersex-devel@list.zerties.org
http://list.zerties.org/cgi-bin/mailman/listinfo/ethersex-devel
/* C6-DIVERT: 0 */
#include <avr/io.h>
#include <avr/pgmspace.h>
#include "services/clock/clock.h"
#include "core/pt/pt.h"
#include "core/vfs/vfs.h"
#include "core/vfs/vfs-util.h"
#include "config.h"
#include "hardware/adc/kty/kty81.h"
#ifdef NAMED_PIN_SUPPORT
#include "core/portio/user_config.h"
#endif
#include "protocols/ecmd/sender/ecmd_sender_net.h"
#include "protocols/uip/uip_router.h"
#include "protocols/uip/uip.h"
#include "control6.h"
struct action {
uint8_t started;
struct pt pt;
};
#define TCP_STATE (&uip_conn->appstate.control6_tcp)
#define UDP_STATE (&uip_udp_conn->appstate.control6_udp)
#define UDP_BUF ((struct uip_udpip_hdr *) (uip_appdata - UIP_IPUDPH_LEN))
#include "core/debug.h"
#include "core/tty/tty.h"
//
############################################################################################################################
// Beispiele zum Abfragen auf r2d2 als .php und .sh
//
// Aufruf z.B.:
// wget -q -O - http://ether6terrs/ecmd?c6%20set%20r1%205
//
############################################################################################################################
#include "config.h"
#include "protocols/httplog/httplog.h"
static uint8_t t1=0;
static uint8_t t2=0;
static uint8_t relais;
static uint16_t adc0;
static uint16_t adc1;
static uint16_t adc2;
static uint16_t adc3;
static uint16_t adc4;
static uint16_t adc5;
static uint16_t adc6;
static uint16_t adc7;
struct action action_threads[] = {
{0, {0} }, {0, {0} }, {0, {0} },
};
/* C6-DIVERT: 1 */
uint32_t timers[] = {
-1, -1,
};
/* C6-DIVERT: 2 */
#ifdef C6_CLOCK_USED
clock_datetime_t datetime;
uint8_t last_minute;
#ifndef CLOCK_SUPPORT
#error Please define clock support
#endif
#if defined(CLOCK_DATETIME_SUPPORT) || defined(CLOCK_DATE_SUPPORT) ||
defined(CLOCK_TIME_SUPPORT)
#else
#error Please define clock date/time support
#endif
#endif
#include "hardware/lcd/hr20.h"
#include "hardware/adc/hr20-temp.h"
#define C6_ECMD_USED 1
#ifndef ECMD_PARSER_SUPPORT
#error Please define ECMD
#endif
#include "control6/ecmd.c"
/*
-- Ethersex META --
ecmd_feature(c6_get, "c6 get ", VARNAME, Display the current value of the
Control6 ECMD variable)
ecmd_feature(c6_set, "c6 set ", VARNAME VALUE, Set an new value on the
Control6 ECMD variable)
*/
const char PROGMEM seccnt_text[] = "seccnt";
const char PROGMEM r1_text[] = "r1";
const char PROGMEM r2_text[] = "r2";
const char PROGMEM r3_text[] = "r3";
const char PROGMEM r4_text[] = "r4";
const char PROGMEM r5_text[] = "r5";
const char PROGMEM r6_text[] = "r6";
const char PROGMEM r7_text[] = "r7";
const char PROGMEM r8_text[] = "r8";
const char PROGMEM state_text[] = "state";
uint32_t current_time;
#ifndef CLOCK_SUPPORT
#error Please define clock support
#endif
#ifndef ADC_SUPPORT
#error Please define adc support
#endif
#include "hardware/adc/adc.h"
static uint16_t
control6_get_adc(uint8_t sensorchannel){
return adc_get(sensorchannel);
}
static uint8_t global_started;
/* C6-DIVERT: 3 */
struct pin_state {
uint8_t old_state;
};
struct pin_state pin_states[] ={
};
/* C6-DIVERT: 4 */
#ifdef C6_ECMD_USED
#define C6_TYPE_ 0
#define d_ d_uint8_t
struct c6_option_t {
PGM_P name;
struct c6_vario_type value;
};
struct c6_option_t c6_ecmd_vars[] = {
/* hier alle variablen definieren */
{ .name = seccnt_text, .value = { .type = C6_TYPE_uint8_t, .data.d_uint8_t = 0
} },
#define seccnt (c6_ecmd_vars[ 0 ].value.data.d_uint8_t)
{ .name = r1_text, .value = { .type = C6_TYPE_uint16_t, .data.d_uint16_t = 0 }
},
#define r1 (c6_ecmd_vars[ 1 ].value.data.d_uint16_t)
{ .name = r2_text, .value = { .type = C6_TYPE_uint16_t, .data.d_uint16_t = 0 }
},
#define r2 (c6_ecmd_vars[ 2 ].value.data.d_uint16_t)
{ .name = r3_text, .value = { .type = C6_TYPE_uint16_t, .data.d_uint16_t = 0 }
},
#define r3 (c6_ecmd_vars[ 3 ].value.data.d_uint16_t)
{ .name = r4_text, .value = { .type = C6_TYPE_uint16_t, .data.d_uint16_t = 0 }
},
#define r4 (c6_ecmd_vars[ 4 ].value.data.d_uint16_t)
{ .name = r5_text, .value = { .type = C6_TYPE_uint16_t, .data.d_uint16_t = 0 }
},
#define r5 (c6_ecmd_vars[ 5 ].value.data.d_uint16_t)
{ .name = r6_text, .value = { .type = C6_TYPE_uint16_t, .data.d_uint16_t = 0 }
},
#define r6 (c6_ecmd_vars[ 6 ].value.data.d_uint16_t)
{ .name = r7_text, .value = { .type = C6_TYPE_uint16_t, .data.d_uint16_t = 0 }
},
#define r7 (c6_ecmd_vars[ 7 ].value.data.d_uint16_t)
{ .name = r8_text, .value = { .type = C6_TYPE_uint16_t, .data.d_uint16_t = 0 }
},
#define r8 (c6_ecmd_vars[ 8 ].value.data.d_uint16_t)
{ .name = state_text, .value = { .type = C6_TYPE_uint8_t, .data.d_uint8_t = 0 }
},
#define state (c6_ecmd_vars[ 9 ].value.data.d_uint8_t)
};
uint8_t control6_set(const char *varname, struct c6_vario_type value) {
uint8_t i;
for(i = 0;i < 10 ;i ++) {
if (strcmp_P(varname, c6_ecmd_vars[i].name) == 0) {
c6_ecmd_vars[i].value = value;
return 1;
}
}
return 0;
}
uint8_t control6_get(const char *varname, struct c6_vario_type *value) {
uint8_t i;
for(i = 0;i < 10 ;i ++) {
if (strcmp_P(varname, c6_ecmd_vars[i].name) == 0) {
*value = c6_ecmd_vars[i].value;
return 1;
}
}
return 0;
}
#endif /* C6_ECMD_USED */
/* C6-DIVERT: 5 */
/* Thread: 47 */
static
PT_THREAD(action_thread_boot(struct pt *pt)) {
PT_BEGIN(pt);
if (state==0) {
timers[0] = current_time;; PT_WAIT_UNTIL(pt, (current_time - timers[0]) >=
(10));;
state=1;
do { uip_slen = snprintf_P ( &uip_buf[UIP_LLH_LEN +
UIP_IPUDPH_LEN], UIP_BUFSIZE - UIP_IPUDPH_LEN, PSTR("%s start %s\n"),
CONF_HOSTNAME,VERSION_STRING_LONG);
{ uip_udp_conn_t conn;
uip_ipaddr_t ip; uip_ipaddr(&ip, 192, 168, 178, 53) ;
uip_ipaddr_copy(conn.ripaddr, &ip);
conn.lport = HTONS(2701);
conn.rport = HTONS(2701);
uip_udp_conn = &conn;
uip_process(UIP_UDP_SEND_CONN);
router_output();
uip_slen = 0;
}
PT_YIELD(pt);
} while(0);
;
}
if (relais!=PINC) {
relais=PINC;
do { uip_slen = snprintf_P ( &uip_buf[UIP_LLH_LEN +
UIP_IPUDPH_LEN], UIP_BUFSIZE - UIP_IPUDPH_LEN, PSTR("%s R %d"),
CONF_HOSTNAME,relais);
{ uip_udp_conn_t conn;
uip_ipaddr_t ip; uip_ipaddr(&ip, 192, 168, 178, 53) ;
uip_ipaddr_copy(conn.ripaddr, &ip);
conn.lport = HTONS(2701);
conn.rport = HTONS(2701);
uip_udp_conn = &conn;
uip_process(UIP_UDP_SEND_CONN);
router_output();
uip_slen = 0;
}
PT_YIELD(pt);
} while(0);
;
}
PT_RESTART(pt);
PT_END(pt); /* mmh, not really nice, since not reached.
I hope the compiler is intelligent enough *g* */
}
/* Thread: 60 */
static
PT_THREAD(action_thread_Relaistimer(struct pt *pt)) {
PT_BEGIN(pt);
seccnt++;
if (seccnt==50){
seccnt=0;
}
if ( r1 > 0 && seccnt == 0 ) {
r1--;
PIN_SET(RELAIS1);
}
if ( r2 > 0 && seccnt == 0 ) {
r2--;
PIN_SET(RELAIS2);
}
if ( r3 > 0 && seccnt == 0 ) {
r3--;
PIN_SET(RELAIS3);
}
if ( r4 > 0 && seccnt == 0 ) {
r4--;
PIN_SET(RELAIS4);
}
if ( r5 > 0 && seccnt == 0 ) {
r5--;
PIN_SET(RELAIS5);
}
if ( r6 > 0 && seccnt == 0 ) {
r6--;
PIN_SET(RELAIS6);
}
if ( r7 > 0 && seccnt == 0 ) {
r7--;
PIN_SET(RELAIS7);
}
if ( r8 > 0 && seccnt == 0 ) {
r8--;
PIN_SET(RELAIS8);
}
if ( r1 == 0 ) {
PIN_CLEAR(RELAIS1);
}
if ( r2 == 0 ) {
PIN_CLEAR(RELAIS2);
}
if ( r3 == 0 ) {
PIN_CLEAR(RELAIS3);
}
if ( r4 == 0 ) {
PIN_CLEAR(RELAIS4);
}
if ( r5 == 0 ) {
PIN_CLEAR(RELAIS5);
}
if ( r6 == 0 ) {
PIN_CLEAR(RELAIS6);
}
if ( r7 == 0 ) {
PIN_CLEAR(RELAIS7);
}
if ( r8 == 0 ) {
PIN_CLEAR(RELAIS8);
}
PT_RESTART(pt);
PT_END(pt); /* mmh, not really nice, since not reached.
I hope the compiler is intelligent enough *g* */
}
/* Thread: 126 */
static
PT_THREAD(action_thread_radc(struct pt *pt)) {
PT_BEGIN(pt);
timers[1] = current_time;
relais=PINC;
adc0 = control6_get_adc(0);
adc1 = control6_get_adc(1);
adc2 = control6_get_adc(2);
adc3 = control6_get_adc(3);
adc4 = control6_get_adc(4);
adc5 = control6_get_adc(5);
adc6 = control6_get_adc(6);
adc7 = control6_get_adc(7);
do { uip_slen = snprintf_P ( &uip_buf[UIP_LLH_LEN +
UIP_IPUDPH_LEN], UIP_BUFSIZE - UIP_IPUDPH_LEN, PSTR("%s RA %d %d %d %d %d %d %d
%d %d"), CONF_HOSTNAME,relais,adc0,adc1,adc2,adc3,adc4,adc5,adc6,adc7);
{ uip_udp_conn_t conn;
uip_ipaddr_t ip; uip_ipaddr(&ip, 192, 168, 178, 53) ;
uip_ipaddr_copy(conn.ripaddr, &ip);
conn.lport = HTONS(2701);
conn.rport = HTONS(2701);
uip_udp_conn = &conn;
uip_process(UIP_UDP_SEND_CONN);
router_output();
uip_slen = 0;
}
PT_YIELD(pt);
} while(0);
;
PT_WAIT_UNTIL(pt, (current_time - timers[1]) >= 10);
PT_RESTART(pt);
PT_END(pt); /* mmh, not really nice, since not reached.
I hope the compiler is intelligent enough *g* */
}
/* C6-DIVERT: 9 */
void control6_init(void) {
DDR_CONFIG_OUT(RELAIS1);
DDR_CONFIG_OUT(RELAIS2);
DDR_CONFIG_OUT(RELAIS3);
DDR_CONFIG_OUT(RELAIS4);
DDR_CONFIG_OUT(RELAIS5);
DDR_CONFIG_OUT(RELAIS6);
DDR_CONFIG_OUT(RELAIS7);
DDR_CONFIG_OUT(RELAIS8);
}
/* C6-DIVERT: 10 */
void control6_run(void) { current_time = clock_get_uptime();
/* C6-DIVERT: 11 */
#ifdef C6_CLOCK_USED
clock_localtime(&datetime, clock_get_time());
#endif
;
;
;
;
;
;
;
;
;
;
if ( global_started == 0 ) {
action_threads[1].started = 1;;
PIN_CLEAR(RELAIS1);
PIN_CLEAR(RELAIS2);
PIN_CLEAR(RELAIS3);
PIN_CLEAR(RELAIS3);
PIN_CLEAR(RELAIS4);
PIN_CLEAR(RELAIS5);
PIN_CLEAR(RELAIS6);
PIN_CLEAR(RELAIS7);
PIN_CLEAR(RELAIS8);
action_threads[0].started = 1;;
action_threads[2].started = 1;
}
if (!(PIND & 0b00000100)) t1++; else t1=0;
if (t1==5) {if (r1>0) {r1=0;} else {r1=180;}}
if (!(PIND & 0b00001000)) t2++; else t2=0;
if (t2==5) {if (r2>0) {r2=0;} else {r2=180;}}
/* C6-DIVERT: 12 */
if (action_threads[0].started) { action_threads[0].started =
(PT_SCHEDULE (action_thread_boot(&action_threads[0].pt))); }
if (action_threads[1].started) { action_threads[1].started =
(PT_SCHEDULE (action_thread_Relaistimer(&action_threads[1].pt))); }
if (action_threads[2].started) { action_threads[2].started =
(PT_SCHEDULE (action_thread_radc(&action_threads[2].pt))); }/* C6-DIVERT: 13
*/
/* C6-DIVERT: 14 */
#ifdef C6_CLOCK_USED
last_minute = datetime.min;
#endif
global_started = 1;
}
/*
-- Ethersex META --
header(control6/control6.h)
init(control6_init)
timer(1, control6_run())
*/
_______________________________________________
Ethersex-devel mailing list
Ethersex-devel@list.zerties.org
http://list.zerties.org/cgi-bin/mailman/listinfo/ethersex-devel