more work on switching to new COM and TIMER stack.
This commit is contained in:
@@ -297,21 +297,21 @@ void _processSendStatsMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *nodeMsg)
|
||||
if (packetsOutInt) {
|
||||
double packetsOut;
|
||||
double collisions;
|
||||
double aborted;
|
||||
double busy;
|
||||
double collisionsPercentage=0.0;
|
||||
double abortedPercentage=0.0;
|
||||
double busyPercentage=0.0;
|
||||
|
||||
packetsOut=(double) packetsOutInt;
|
||||
collisions=(double)AQH_SendStatsMsg_GetCollisions(nodeMsg);
|
||||
aborted=(double)AQH_SendStatsMsg_GetAborted(nodeMsg);
|
||||
busy=(double)AQH_SendStatsMsg_GetBusyErrors(nodeMsg);
|
||||
|
||||
collisionsPercentage=collisions*100.0/packetsOut;
|
||||
abortedPercentage=aborted*100.0/packetsOut;
|
||||
busyPercentage=busy*100.0/packetsOut;
|
||||
|
||||
_publishInt(ep, AQH_SendStatsMsg_GetUid(nodeMsg), 0, "net/packetsOut", packetsOutInt);
|
||||
_publishInt(ep, AQH_SendStatsMsg_GetUid(nodeMsg), 0, "net/collisions", (int) AQH_SendStatsMsg_GetCollisions(nodeMsg));
|
||||
_publishDouble(ep, AQH_SendStatsMsg_GetUid(nodeMsg), 0, "net/collisionsPercent", collisionsPercentage);
|
||||
_publishDouble(ep, AQH_SendStatsMsg_GetUid(nodeMsg), 0, "net/abortedPercent", abortedPercentage);
|
||||
_publishDouble(ep, AQH_SendStatsMsg_GetUid(nodeMsg), 0, "net/busyPercent", busyPercentage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_SENDSTATS_UID 0
|
||||
#define AQH_MSG_OFFS_SENDSTATS_PACKETSOUT 4
|
||||
#define AQH_MSG_OFFS_SENDSTATS_COLLISIONS 6
|
||||
#define AQH_MSG_OFFS_SENDSTATS_ABORTED 8
|
||||
#define AQH_MSG_OFFS_SENDSTATS_NOBUFFER 10
|
||||
#define AQH_MSG_OFFS_SENDSTATS_UID 0 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_SENDSTATS_PACKETSOUT 4 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_SENDSTATS_COLLISIONS 6 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_SENDSTATS_BUSY 8 /* 2 bytes */
|
||||
|
||||
#define AQH_MSG_SENDSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_ABORTED+2)
|
||||
#define AQH_MSG_SENDSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_BUSY+2)
|
||||
|
||||
|
||||
|
||||
@@ -49,16 +48,9 @@ uint16_t AQH_SendStatsMsg_GetCollisions(const GWEN_MSG *msg)
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_SendStatsMsg_GetAborted(const GWEN_MSG *msg)
|
||||
uint16_t AQH_SendStatsMsg_GetBusyErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_ABORTED, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_SendStatsMsg_GetNoBufferErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_NOBUFFER, 0);
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_BUSY, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,15 +60,14 @@ void AQH_SendStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_COMSENDSTATS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_SENDSTATS_MINSIZE)) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: SENDSTATS %s (uid=0x%08x, out=%d, collisions=%d, aborted=%d, no buffer=%d)\n",
|
||||
"0x%02x->0x%02x: SENDSTATS %s (uid=0x%08x, out=%d, collisions=%d, busy line=%d)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_SendStatsMsg_GetUid(msg),
|
||||
AQH_SendStatsMsg_GetPacketsOut(msg),
|
||||
AQH_SendStatsMsg_GetCollisions(msg),
|
||||
AQH_SendStatsMsg_GetAborted(msg),
|
||||
AQH_SendStatsMsg_GetNoBufferErrors(msg));
|
||||
AQH_SendStatsMsg_GetBusyErrors(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
AQHOME_API uint32_t AQH_SendStatsMsg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_SendStatsMsg_GetPacketsOut(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_SendStatsMsg_GetCollisions(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_SendStatsMsg_GetAborted(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_SendStatsMsg_GetNoBufferErrors(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_SendStatsMsg_GetBusyErrors(const GWEN_MSG *msg);
|
||||
|
||||
|
||||
AQHOME_API void AQH_SendStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
@@ -327,7 +327,7 @@ void _handleMsgComSendStat(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, c
|
||||
}
|
||||
AQH_NodeInfo_SetStatsPacketsOut(ni, AQH_SendStatsMsg_GetPacketsOut(msg));
|
||||
AQH_NodeInfo_SetStatsCollisions(ni, AQH_SendStatsMsg_GetCollisions(msg));
|
||||
AQH_NodeInfo_SetStatsAborted(ni, AQH_SendStatsMsg_GetAborted(msg));
|
||||
AQH_NodeInfo_SetStatsBusy(ni, AQH_SendStatsMsg_GetBusyErrors(msg));
|
||||
AQH_NodeDb_SetModified(xmgr->nodeDb);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
<member name="statsAborted" type="uint32_t" maxlen="4">
|
||||
<member name="statsBusy" type="uint32_t" maxlen="4">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
|
||||
@@ -239,7 +239,7 @@
|
||||
.include "comproto_sysstats.asm"
|
||||
.include "comproto_memstats.asm"
|
||||
.include "comproto_pong.asm"
|
||||
; .include "comproto_values.asm"
|
||||
.include "comproto_values.asm"
|
||||
#endif
|
||||
#endif
|
||||
#ifdef MODULES_TWI_MASTER
|
||||
@@ -267,7 +267,11 @@
|
||||
sramTimerWriteStats: .byte 2
|
||||
#endif
|
||||
sramTimerEnqueueValues: .byte 2
|
||||
sramTimerSI7021Measure: .byte 2
|
||||
#ifdef MODULES_SI7021
|
||||
sramTimerSI7021Measure: .byte 2
|
||||
sramTimerSI7021SendTemp: .byte 2
|
||||
sramTimerSI7021SendHumidity: .byte 2
|
||||
#endif
|
||||
#ifdef MODULES_LCD
|
||||
sramPeriodicalLcdMark: .byte 2
|
||||
#endif
|
||||
@@ -301,8 +305,11 @@ timerList:
|
||||
.dw sramPeriodicalLcdMark, periodicalLcdMark, 0, 1 ; every sec
|
||||
.dw sramTimerWriteStats, writeStats, 0, 10
|
||||
#endif
|
||||
#ifdef MODULES_SI7021
|
||||
.dw sramTimerSI7021Measure, SI7021_PeriodicMeasurement, 0, 30 ; every 30s
|
||||
; .dw sramTimerEnqueueValues, Main_SendValueMsg, TIMER_FLAGS_IF_ADDR, 60 ; every 1m
|
||||
.dw sramTimerSI7021SendTemp, sendTemp, TIMER_FLAGS_IF_ADDR, 60 ; every 60s
|
||||
.dw sramTimerSI7021SendHumidity, sendHumidity, TIMER_FLAGS_IF_ADDR, 60 ; every 60s
|
||||
#endif
|
||||
.dw 0 ; end of list
|
||||
|
||||
|
||||
@@ -332,6 +339,31 @@ writeStats:
|
||||
|
||||
|
||||
|
||||
#ifdef MODULES_SI7021
|
||||
|
||||
sendHumidity:
|
||||
rcall SI7021_SendHumidity
|
||||
brcs sendHumidity_okay
|
||||
; set timer to 1s to retry later
|
||||
ldi xl, LOW(sramTimerSI7021SendHumidity)
|
||||
ldi xh, HIGH(sramTimerSI7021SendHumidity)
|
||||
rjmp Timer_SetValueTo1s
|
||||
sendHumidity_okay:
|
||||
ret
|
||||
|
||||
|
||||
sendTemp:
|
||||
rcall SI7021_SendTemp
|
||||
brcs sendTemp_okay
|
||||
; set timer to 1s to retry later
|
||||
ldi xl, LOW(sramTimerSI7021SendTemp)
|
||||
ldi xh, HIGH(sramTimerSI7021SendTemp)
|
||||
rjmp Timer_SetValueTo1s
|
||||
sendTemp_okay:
|
||||
ret
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Enqueue a VALUE packet.
|
||||
; Write a VALUE packet.
|
||||
;
|
||||
; IN:
|
||||
; - R16: destination address
|
||||
@@ -25,12 +25,12 @@
|
||||
; - R19:R18: value
|
||||
; - R21:R20: denom (e.g. 100, meaning value must be divided by 100)
|
||||
; - R22: value type
|
||||
; - X : buffer to write to
|
||||
; OUT:
|
||||
; - CFLAG: set if okay, clear otherwise
|
||||
; MODIFIED REGS: R6, R7, R8, R9, R10, R11, R12, R16, R17, X, Y (R3, R4, R15, R16, R17, R18, R19, R20, R21)
|
||||
|
||||
CPRO_EnqueueValue:
|
||||
mov r6, r16
|
||||
CPRO_WriteValue:
|
||||
mov r7, r17
|
||||
mov r8, r18
|
||||
mov r9, r19
|
||||
@@ -38,15 +38,11 @@ CPRO_EnqueueValue:
|
||||
mov r11, r21
|
||||
mov r12, r22
|
||||
|
||||
rcall COM_AllocBufferAndGetXY ; (r16, r17, r21)
|
||||
brcc CPRO_EnqueueValue_error
|
||||
|
||||
ldi r17, COM2_PAYLOAD_FLAGS_UID | (6<<COM2_PAYLOAD_FLAGS_SHIFT_NUM)
|
||||
ldi r18, CPRO_CMD_VALUE
|
||||
push xh
|
||||
push xl
|
||||
mov r16, r6
|
||||
ldi r17, CPRO_PAYLOAD_FLAGS_UID | (6<<CPRO_PAYLOAD_FLAGS_SHIFT_NUM)
|
||||
ldi r18, CPRO_CMD_VALUE
|
||||
rcall cproBeginMsgWithVariablePayload ; (R3, R4, R16, R17, R18, R19, R20, R21, X)
|
||||
rcall COM2_BeginMsgWithVariablePayload ; R3, R4, R16, R17, R18, R19, R20, R21, X
|
||||
st X+, r7 ; 6: value id
|
||||
st X+, r12 ; 7: value type
|
||||
st X+, r8 ; 8: low value
|
||||
@@ -55,16 +51,7 @@ CPRO_EnqueueValue:
|
||||
st X+, r11 ; 11: high denom
|
||||
pop xl
|
||||
pop xh
|
||||
rcall comCalcAndAddChecksumByte ; (R16, R17, R18, R19, X)
|
||||
|
||||
; mark buffer as enqueued with PRIO "normal" (slightly limited number of retries)
|
||||
ldi r20, COM_BUFFER_PRIO_NORMAL
|
||||
rcall COM_EnqueuePacket ; (R15, R16)
|
||||
brcc CPRO_EnqueueValue_error
|
||||
sec
|
||||
ret
|
||||
CPRO_EnqueueValue_error:
|
||||
clc
|
||||
rcall com2CalcAndAddChecksumByte ; (R16, R17, R18, R19, X)
|
||||
ret
|
||||
|
||||
|
||||
|
||||
@@ -441,6 +441,54 @@ si7021Muls16x16_32_done:
|
||||
; ret
|
||||
|
||||
|
||||
|
||||
|
||||
SI7021_SendTemp:
|
||||
lds r16, si7021Flags
|
||||
andi r16, SI7021_FLAGS_TEMP_VALID
|
||||
brne SI7021_SendTemp_haveValue
|
||||
sec
|
||||
ret
|
||||
SI7021_SendTemp_haveValue:
|
||||
ldi r16, 0xff ; destination address
|
||||
ldi r17, VALUE_ID_TEMP1 ; value id
|
||||
ldi r22, AQHOME_VALUETYPE_TEMP
|
||||
lds r18, si7021LastTemp ; value
|
||||
lds r19, si7021LastTemp+1
|
||||
ldi r20, 100 ; denominator
|
||||
clr r21
|
||||
rjmp SI7021_SendValue
|
||||
|
||||
|
||||
|
||||
SI7021_SendHumidity:
|
||||
lds r16, si7021Flags
|
||||
andi r16, SI7021_FLAGS_HUM_VALID
|
||||
brne SI7021_SendHumidity_haveValue
|
||||
clc
|
||||
ret
|
||||
SI7021_SendHumidity_haveValue:
|
||||
ldi r16, 0xff ; destination address
|
||||
ldi r17, VALUE_ID_HUM1 ; value id
|
||||
ldi r22, AQHOME_VALUETYPE_HUMIDITY
|
||||
lds r18, si7021LastHumidity ; value
|
||||
lds r19, si7021LastHumidity+1
|
||||
ldi r20, 1 ; denominator
|
||||
clr r21
|
||||
rjmp SI7021_SendValue
|
||||
|
||||
|
||||
SI7021_SendValue:
|
||||
ldi xl, LOW(com2SendBuffer)
|
||||
ldi xh, HIGH(com2SendBuffer)
|
||||
rcall CPRO_WriteValue
|
||||
rjmp COM2_SendPacket
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SI7021_END:
|
||||
.equ MODULE_SIZE_SI7021 = SI7021_END-SI7021_BEGIN
|
||||
|
||||
|
||||
@@ -148,6 +148,53 @@ Timer_Run_End:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Set timer value.
|
||||
;
|
||||
; Setting a timer to 0 effectively stops the timer.
|
||||
;
|
||||
; IN:
|
||||
; - r16: new timer value (low)
|
||||
; - r17: new timer value (high)
|
||||
; - X : pointer to timer value in SRAM
|
||||
; OUT:
|
||||
; - nothing
|
||||
; REGS: X
|
||||
|
||||
Timer_SetValue:
|
||||
push r15
|
||||
in r15, SREG
|
||||
cli
|
||||
st X+, r16
|
||||
st X+, r17
|
||||
out SREG, r15
|
||||
pop r15
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Set timer value to 1s.
|
||||
;
|
||||
; IN:
|
||||
; - X : pointer to timer value in SRAM
|
||||
; OUT:
|
||||
; - nothing
|
||||
; REGS: X
|
||||
|
||||
Timer_SetValueTo1s:
|
||||
push r16
|
||||
push r17
|
||||
ldi r16, 1
|
||||
clr r17
|
||||
rcall Timer_SetValue
|
||||
pop r17
|
||||
pop r16
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
timerInitTimers:
|
||||
ldi zl, LOW(timerList*2)
|
||||
ldi zh, HIGH(timerList*2)
|
||||
|
||||
Reference in New Issue
Block a user