removed idle time calculation (doesn't work so far).
This commit is contained in:
@@ -26,9 +26,8 @@
|
|||||||
#define AQH_MSG_OFFS_MEMSTATS_MAXBUFFERSUSED 11 /* 1 byte */
|
#define AQH_MSG_OFFS_MEMSTATS_MAXBUFFERSUSED 11 /* 1 byte */
|
||||||
#define AQH_MSG_OFFS_MEMSTATS_SENDNOBUFFER 12 /* 2 bytes */
|
#define AQH_MSG_OFFS_MEMSTATS_SENDNOBUFFER 12 /* 2 bytes */
|
||||||
#define AQH_MSG_OFFS_MEMSTATS_RECVNOBUFFER 14 /* 2 bytes */
|
#define AQH_MSG_OFFS_MEMSTATS_RECVNOBUFFER 14 /* 2 bytes */
|
||||||
#define AQH_MSG_OFFS_MEMSTATS_IDLEPERCENT 16 /* 1 byte */
|
|
||||||
|
|
||||||
#define AQH_MSG_MEMSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_IDLEPERCENT+1)
|
#define AQH_MSG_MEMSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_RECVNOBUFFER+2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -80,23 +79,15 @@ uint16_t AQH_MemStatsMsg_GetRecvNoBufferErrors(const GWEN_MSG *msg)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t AQH_MemStatsMsg_GetIdlePercentage(const GWEN_MSG *msg)
|
|
||||||
{
|
|
||||||
return AQH_NodeMsg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_IDLEPERCENT, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AQH_MemStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
void AQH_MemStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||||
{
|
{
|
||||||
GWEN_Buffer_AppendArgs(dbuf,
|
GWEN_Buffer_AppendArgs(dbuf,
|
||||||
"0x%02x->0x%02x: MEMSTATS %s (uid=0x%08x, uptime=%d, idle=%d, stackptr=%d[%04x], buffers used=%d(max=%d), no sendbuf errs=%d, no recvbuf=%d)\n",
|
"0x%02x->0x%02x: MEMSTATS %s (uid=0x%08x, uptime=%d, stackptr=%d[%04x], buffers used=%d(max=%d), no sendbuf errs=%d, no recvbuf=%d)\n",
|
||||||
AQH_NodeMsg_GetSourceAddress(msg),
|
AQH_NodeMsg_GetSourceAddress(msg),
|
||||||
AQH_NodeMsg_GetDestAddress(msg),
|
AQH_NodeMsg_GetDestAddress(msg),
|
||||||
sText,
|
sText,
|
||||||
(unsigned int) AQH_MemStatsMsg_GetUid(msg),
|
(unsigned int) AQH_MemStatsMsg_GetUid(msg),
|
||||||
AQH_MemStatsMsg_GetSeconds(msg),
|
AQH_MemStatsMsg_GetSeconds(msg),
|
||||||
AQH_MemStatsMsg_GetIdlePercentage(msg),
|
|
||||||
AQH_MemStatsMsg_GetStackPtr(msg),
|
AQH_MemStatsMsg_GetStackPtr(msg),
|
||||||
AQH_MemStatsMsg_GetStackPtr(msg),
|
AQH_MemStatsMsg_GetStackPtr(msg),
|
||||||
AQH_MemStatsMsg_GetBuffersUsed(msg),
|
AQH_MemStatsMsg_GetBuffersUsed(msg),
|
||||||
|
|||||||
@@ -23,9 +23,8 @@
|
|||||||
#define AQH_MSG_OFFS_SYSSTATS_UID 4 /* 4 bytes */
|
#define AQH_MSG_OFFS_SYSSTATS_UID 4 /* 4 bytes */
|
||||||
#define AQH_MSG_OFFS_SYSSTATS_COMIRQS 8 /* 2 bytes */
|
#define AQH_MSG_OFFS_SYSSTATS_COMIRQS 8 /* 2 bytes */
|
||||||
#define AQH_MSG_OFFS_SYSSTATS_TIMERIRQS 10 /* 2 bytes */
|
#define AQH_MSG_OFFS_SYSSTATS_TIMERIRQS 10 /* 2 bytes */
|
||||||
#define AQH_MSG_OFFS_SYSSTATS_IDLEPERCENT 12 /* 1 byte */
|
|
||||||
|
|
||||||
#define AQH_MSG_MEMSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SYSSTATS_IDLEPERCENT+1)
|
#define AQH_MSG_MEMSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SYSSTATS_TIMERIRQS+2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -56,23 +55,15 @@ uint16_t AQH_SysStatsMsg_GetTimerInterrupts(const GWEN_MSG *msg)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t AQH_SysStatsMsg_GetIdlePercentage(const GWEN_MSG *msg)
|
|
||||||
{
|
|
||||||
return AQH_NodeMsg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SYSSTATS_IDLEPERCENT, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AQH_SysStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
void AQH_SysStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||||
{
|
{
|
||||||
GWEN_Buffer_AppendArgs(dbuf,
|
GWEN_Buffer_AppendArgs(dbuf,
|
||||||
"0x%02x->0x%02x: SYSSTATS %s (uid=0x%08x, uptime=%d, idle=%d, com irqs=%d, timer irqs=%d)\n",
|
"0x%02x->0x%02x: SYSSTATS %s (uid=0x%08x, uptime=%d, com irqs=%d, timer irqs=%d)\n",
|
||||||
AQH_NodeMsg_GetSourceAddress(msg),
|
AQH_NodeMsg_GetSourceAddress(msg),
|
||||||
AQH_NodeMsg_GetDestAddress(msg),
|
AQH_NodeMsg_GetDestAddress(msg),
|
||||||
sText,
|
sText,
|
||||||
(unsigned int) AQH_SysStatsMsg_GetUid(msg),
|
(unsigned int) AQH_SysStatsMsg_GetUid(msg),
|
||||||
AQH_SysStatsMsg_GetSeconds(msg),
|
AQH_SysStatsMsg_GetSeconds(msg),
|
||||||
AQH_SysStatsMsg_GetIdlePercentage(msg),
|
|
||||||
AQH_SysStatsMsg_GetComInterrupts(msg),
|
AQH_SysStatsMsg_GetComInterrupts(msg),
|
||||||
AQH_SysStatsMsg_GetTimerInterrupts(msg));
|
AQH_SysStatsMsg_GetTimerInterrupts(msg));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ CPRO_EnqueueMemStats:
|
|||||||
push xh
|
push xh
|
||||||
push xl
|
push xl
|
||||||
mov r16, r6
|
mov r16, r6
|
||||||
ldi r17, CPRO_PAYLOAD_FLAGS_UID | CPRO_PAYLOAD_FLAGS_SECONDS | (9<<CPRO_PAYLOAD_FLAGS_SHIFT_NUM)
|
ldi r17, CPRO_PAYLOAD_FLAGS_UID | CPRO_PAYLOAD_FLAGS_SECONDS | (8<<CPRO_PAYLOAD_FLAGS_SHIFT_NUM)
|
||||||
ldi r18, CPRO_CMD_MEMSTATS
|
ldi r18, CPRO_CMD_MEMSTATS
|
||||||
rcall cproBeginMsgWithVariablePayload ; (R3, R4, R16, R17, R18, R19, R20, R21, X)
|
rcall cproBeginMsgWithVariablePayload ; (R3, R4, R16, R17, R18, R19, R20, R21, X)
|
||||||
; payload
|
; payload
|
||||||
@@ -54,12 +54,6 @@ CPRO_EnqueueMemStats:
|
|||||||
st X+, r17 ; recvNoBuffer
|
st X+, r17 ; recvNoBuffer
|
||||||
lds r17, comStatsRecvNoBuffer+1
|
lds r17, comStatsRecvNoBuffer+1
|
||||||
st X+, r17
|
st X+, r17
|
||||||
push xl
|
|
||||||
push xh
|
|
||||||
rcall Timer_CalcIdle ; (r16, r17, r18, r24, r25, X)
|
|
||||||
pop xh
|
|
||||||
pop xl
|
|
||||||
st X+, r16
|
|
||||||
pop xl
|
pop xl
|
||||||
pop xh
|
pop xh
|
||||||
rcall comCalcAndAddChecksumByte ; (R16, R17, R18, R19, X)
|
rcall comCalcAndAddChecksumByte ; (R16, R17, R18, R19, X)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ CPRO_EnqueueSysStats:
|
|||||||
push xh
|
push xh
|
||||||
push xl
|
push xl
|
||||||
mov r16, r6
|
mov r16, r6
|
||||||
ldi r17, CPRO_PAYLOAD_FLAGS_UID | CPRO_PAYLOAD_FLAGS_SECONDS | (9<<CPRO_PAYLOAD_FLAGS_SHIFT_NUM)
|
ldi r17, CPRO_PAYLOAD_FLAGS_UID | CPRO_PAYLOAD_FLAGS_SECONDS | (4<<CPRO_PAYLOAD_FLAGS_SHIFT_NUM)
|
||||||
ldi r18, CPRO_CMD_SYSSTATS
|
ldi r18, CPRO_CMD_SYSSTATS
|
||||||
rcall cproBeginMsgWithVariablePayload ; (R3, R4, R16, R17, R18, R19, R20, R21, X)
|
rcall cproBeginMsgWithVariablePayload ; (R3, R4, R16, R17, R18, R19, R20, R21, X)
|
||||||
; payload
|
; payload
|
||||||
@@ -47,13 +47,6 @@ CPRO_EnqueueSysStats:
|
|||||||
st X+, r17 ; timer interrupts
|
st X+, r17 ; timer interrupts
|
||||||
lds r17, timerInterrupts+1
|
lds r17, timerInterrupts+1
|
||||||
st X+, r17
|
st X+, r17
|
||||||
|
|
||||||
push xl
|
|
||||||
push xh
|
|
||||||
rcall Timer_CalcIdle ; (r16, r17, r18, r24, r25, X)
|
|
||||||
pop xh
|
|
||||||
pop xl
|
|
||||||
st X+, r16 ; idle percentage
|
|
||||||
pop xl
|
pop xl
|
||||||
pop xh
|
pop xh
|
||||||
rcall comCalcAndAddChecksumByte ; (R16, R17, R18, R19, X)
|
rcall comCalcAndAddChecksumByte ; (R16, R17, R18, R19, X)
|
||||||
|
|||||||
@@ -71,8 +71,6 @@ main_loop:
|
|||||||
; cbi PORTA, PORTA2 ; debug (on)
|
; cbi PORTA, PORTA2 ; debug (on)
|
||||||
; sbi PORTA, PORTA2 ; debug (off)
|
; sbi PORTA, PORTA2 ; debug (off)
|
||||||
|
|
||||||
rcall Timer_BeforeSleep
|
|
||||||
|
|
||||||
; only modify SE, SM1 and SM0
|
; only modify SE, SM1 and SM0
|
||||||
in r16, MCUCR
|
in r16, MCUCR
|
||||||
ldi r17, (1<<SE) | (1<<SM1) | (1<<SM0)
|
ldi r17, (1<<SE) | (1<<SM1) | (1<<SM0)
|
||||||
@@ -81,7 +79,6 @@ main_loop:
|
|||||||
ori r16, (1<<SE) ; sleep mode "idle", enable
|
ori r16, (1<<SE) ; sleep mode "idle", enable
|
||||||
out MCUCR, r16
|
out MCUCR, r16
|
||||||
sleep ; sleep, wait for interrupt
|
sleep ; sleep, wait for interrupt
|
||||||
rcall Timer_AfterSleep
|
|
||||||
rjmp main_loop
|
rjmp main_loop
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
.equ TIMER_FLAGS_IF_ADDR = 1
|
.equ TIMER_FLAGS_IF_ADDR = 1
|
||||||
|
|
||||||
.equ TIMER_STATES_MASK = 7
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -30,9 +29,6 @@ timerModuleTickCounter: .byte 1
|
|||||||
timerTicksSinceLastRun: .byte 2
|
timerTicksSinceLastRun: .byte 2
|
||||||
timerModuleCounterSecs: .byte 4
|
timerModuleCounterSecs: .byte 4
|
||||||
timerInterrupts: .byte 2
|
timerInterrupts: .byte 2
|
||||||
timerStateBeforeSleep: .byte 1
|
|
||||||
timerStatePos: .byte 1
|
|
||||||
timerStates: .byte TIMER_STATES_MASK+1
|
|
||||||
timerModuleData_end:
|
timerModuleData_end:
|
||||||
|
|
||||||
|
|
||||||
@@ -248,68 +244,6 @@ timerCallR19R18:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Timer_AfterSleep:
|
|
||||||
in r16, TCNT0
|
|
||||||
sts timerStateBeforeSleep, r16
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Timer_BeforeSleep:
|
|
||||||
in r16, TCNT0 ; read counter value
|
|
||||||
lds r17, timerStateBeforeSleep
|
|
||||||
sub r16, r17
|
|
||||||
brcc Timer_BeforeSleep_l1
|
|
||||||
ldi r17, 98-1
|
|
||||||
add r16, r17
|
|
||||||
Timer_BeforeSleep_l1:
|
|
||||||
ldi xl, LOW(timerStates)
|
|
||||||
ldi xh, HIGH(timerStates)
|
|
||||||
lds r18, timerStatePos
|
|
||||||
clr r17
|
|
||||||
add xl, r18
|
|
||||||
adc xh, r17
|
|
||||||
st X, r16
|
|
||||||
inc r18
|
|
||||||
andi r18, TIMER_STATES_MASK
|
|
||||||
sts timerStatePos, r18
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; Calculate aproximate idle percentage
|
|
||||||
;
|
|
||||||
; IN:
|
|
||||||
; OUT:
|
|
||||||
; - R16: approximate idle percentage (between 0 and 97)
|
|
||||||
; REGS: r16, r17, r18, r24, r25, X
|
|
||||||
|
|
||||||
Timer_CalcIdle:
|
|
||||||
ldi xl, LOW(timerStates)
|
|
||||||
ldi xh, HIGH(timerStates)
|
|
||||||
ldi r18, TIMER_STATES_MASK+1
|
|
||||||
clr r24
|
|
||||||
clr r25
|
|
||||||
clr r17
|
|
||||||
Timer_CalcIdle_loop:
|
|
||||||
ld r16, X+
|
|
||||||
add r24, r16
|
|
||||||
adc r25, r17
|
|
||||||
dec r18
|
|
||||||
brne Timer_CalcIdle_loop
|
|
||||||
lsr r25
|
|
||||||
ror r24
|
|
||||||
lsr r25
|
|
||||||
ror r24
|
|
||||||
lsr r25
|
|
||||||
ror r24
|
|
||||||
mov r16, r24
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; OC0A interrupt handler
|
; OC0A interrupt handler
|
||||||
;
|
;
|
||||||
|
|||||||
Reference in New Issue
Block a user