-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prototype 1 for error logs #26
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments on use of dynamic memory, time, and error descriptions.
|
||
ErrTab_t* create_err_entry(char* err_desc, ErrType_t type){ | ||
|
||
ErrTab_t* table = malloc(sizeof(ErrTab_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using dynamic memory is not the best for reliability/realtime/safety critical systems. In short: it's nondeterministic, can run out of memory, can leak memory. Best to statically declare a set number of ErrTab_t
(eg, in an array), and then set a new assignment when "creating" a new entry.
#define SFUSAT_ERR_TAB_H | ||
|
||
|
||
#include <sys/time.h> //memory concerns for the embedded system? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to use sys/time.h
, but since we're on a bare metal embedded system, there needs to be hardware support for these functions to work (and I don't think TI made them). So, we can keep things simple, remove this include, and just use a uint_32_t
for the timestamp and the methods provided in sfu_rtc.h
to get time.
ER2, | ||
ER3 | ||
|
||
} ErrType_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, we'll need something like this
|
||
struct timeval timestamp; | ||
ErrType_t error_type; //Change later | ||
char* description; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be useful indeed to be able to attach descriptions to errors. However, this would mean the use of dynamic memory in the case of arbitrary strings, or a big waste of memory in the case of static allocations.
Perhaps it'd be better to have enough unique and descriptive ErrType_t
s so that for the majority of entries, they won't need to set a unique description.
For the ones that do, we could create a separate array of character arrays and then have each ErrTab_t
keep track of this index in a small variable (eg, a char
or uint8_t
).
This way, we could have more ErrTab_t
s statically declared and have less memory wasted, while also allowing for a certain amount of ErrTab_t
s to attach a description.
|
||
//need to check return value == 0? | ||
//set timezone to NULL for now | ||
gettimeofday(&table->timestamp, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See getCurrentTime()
or getCurrentRTCTime()
in sfu_rtc.h
.
Setup: - OBC/RF board set 1 compiled with STX strobe in rfTxTestSequence(). - OBC/RF board set 2 compiled with SRX strobe in rfTxTestSequence(). - In UART prompt, enter on both sets: > task resume 10 - Set 1 sample output: ... radio task (0x0) S 0x3d < 0x0f tx_underflowed:no tx_numbytes:0 S 0x3d < 0x0f TX FIFO_BYTES_AVAILABLE: 0xf S 0xbd < 0x00 RX FIFO_BYTES_AVAILABLE: 0x0 S 0x3d < 0x0f 62 Bytes Radio TX FIFO written AFTER: tx_underflowed:no tx_numbytes:62 S 0x35 < 0x02 STX strobed... S 0x3d < 0x24 StatusByte: 0x24 radio task (0x0) S 0x3d < 0x0f tx_underflowed:no tx_numbytes:0 S 0x3d < 0x0f TX FIFO_BYTES_AVAILABLE: 0xf S 0xbd < 0x00 RX FIFO_BYTES_AVAILABLE: 0x0 S 0x3d < 0x0f 62 Bytes Radio TX FIFO written AFTER: tx_underflowed:no tx_numbytes:62 S 0x35 < 0x02 STX strobed... S 0x3d < 0x24 StatusByte: 0x24 radio task (0x0) S 0x3d < 0x0f tx_underflowed:no tx_numbytes:0 S 0x3d < 0x0f TX FIFO_BYTES_AVAILABLE: 0xf S 0xbd < 0x00 RX FIFO_BYTES_AVAILABLE: 0x0 S 0x3d < 0x0f 62 Bytes Radio TX FIFO written AFTER: tx_underflowed:no tx_numbytes:62 S 0x35 < 0x02 STX strobed... S 0x3d < 0x24 StatusByte: 0x24 - Set 2 sample output: ... radio task (0x0) S 0x3d < 0x02 tx_underflowed:no tx_numbytes:62 S 0x3d < 0x02 TX FIFO_BYTES_AVAILABLE: 0x2 S 0xbd < 0x0f RX FIFO_BYTES_AVAILABLE: 0xf S 0x3d < 0x02 Radio did not write AFTER: tx_underflowed:no tx_numbytes:62 S 0x34 < 0x02 STX strobed... S 0x3d < 0x12 StatusByte: 0x12 RX Byte #0: 3e RX Byte #1: 10 RX Byte #2: 02 RX Byte #3: 03 RX Byte #4: 04 RX Byte #5: 05 RX Byte #6: 06 RX Byte #7: 07 RX Byte #8: 08 RX Byte #9: 09 RX Byte #10: 0a RX Byte #11: 0b RX Byte #12: 0c RX Byte #13: 0d RX Byte #14: 0e RX Byte #15: 0f RX Byte #16: 10 RX Byte #17: 11 RX Byte #18: 12 RX Byte #19: 13 RX Byte #20: 14 RX Byte #21: 15 RX Byte #22: 16 RX Byte #23: 17 RX Byte #24: 18 RX Byte #25: 19 RX Byte #26: 1a RX Byte #27: 1b RX Byte #28: 1c RX Byte #29: 1d RX Byte #30: 1e RX Byte #31: 1f RX Byte #32: 20 RX Byte #33: 21 RX Byte #34: 22 RX Byte #35: 23 RX Byte #36: 24 RX Byte #37: 25 RX Byte #38: 26 RX Byte #39: 27 RX Byte #40: 28 RX Byte #41: 29 RX Byte #42: 2a RX Byte #43: 2b RX Byte #44: 2c RX Byte #45: 2d RX Byte #46: 2e RX Byte #47: 2f RX Byte #48: 30 RX Byte #49: 31 RX Byte #50: 32 RX Byte #51: 33 RX Byte #52: 34 RX Byte #53: 35 RX Byte #54: 36 RX Byte #55: 37 RX Byte #56: 38 RX Byte #57: 39 RX Byte #58: 3a RX Byte #59: 3b RX Byte #60: 3c RX Byte #61: 3d RX Byte #62: e8 RX Byte #63: ba Misc: - Fix calculation of fifo bytes in writeToTxFIFO. - TODO: readFromRxFIFO changed to always queuering FIFO_RX; change to check only when needed. - Create IS_STATE macro to check state easily.
Do not merge
For Issue #9
I made the initial table structure for the errors that will be held in a queue.
Questions: