-
Notifications
You must be signed in to change notification settings - Fork 4
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
Fwxv 999 warrenxu 103 hw #232
Conversation
projects/queues/src/main.c
Outdated
} | ||
TASK(task2, TASK_STACK_512) { | ||
LOG_DEBUG("Task 2 initialized!\n"); | ||
const char outstr[ITEM_SZ]; |
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.
You should initialize your array like so
const char outstr[ITEM_SZ] = {};
projects/queues/src/main.c
Outdated
uint32_t receive = 0; | ||
while (true) { | ||
// Your code goes here | ||
ret = queue_receive(&s_queue1, &receive, 1000); |
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.
This &receive
, doesn't really make sense. You're trying to put the item you receive in receive
, but the receive size is only 4 bytes, while the item size is 6 bytes
projects/queues/src/main.c
Outdated
uint32_t to_send = 0; | ||
while (true) { | ||
// Your code goes here | ||
ret = queue_send(&s_queue1, s_list[to_send], 0); |
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.
You want to use &s_list[to_send]
because this function takes in the address
of the value you want to send, not the value itself
projects/queues/src/main.c
Outdated
LOG_DEBUG("write to queue failed\n"); | ||
} | ||
delay_ms(100); | ||
++to_send; |
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.
What about when to_send
is greater than 5? What happens then?
projects/queues/src/main.c
Outdated
delay_ms(100); | ||
++to_send; | ||
if (to_send >= 5) { | ||
ret = STATUS_CODE_OUT_OF_RANGE; |
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.
You should just use % QUEUE_LEN
. That'll just go back to the first item
fw 102 tasks