I want to send a mail item from Thread X to Thread Y. In that mail I want either Thread X or Thread Z's address, so that Thread Y knows where to send responses/data back to.
I wanted to include Thread X's or Z's osMailIdQ inside of the structure I'm mailing over to Thread Y. That way, when mail comes in, I can just use the rsvp address to send responses back to if needed.
This causes a hard fault.
typedef struct { uint16_t id[10]; uint8_t len; osMailQId target_address; }mailStruct; ... mail = (mailStruct*)osMailAlloc(ThreadY_request_mbox, osWaitForever); bundle->id[0]=1; bundle->id[1]=4; bundle->id[2]=2; bundle->len=3; bundle->target_address = ThreadX_data_mbox; //causes hard fault osMailPut(ThreadY_request_mbox, bundle);
I'm not sure why it's causing a fault. Maybe for the same reason that the debugger always shows 0x0000000 for the mail box id? Maybe because in some parts of the OS like create thread osMailIdQ is a const? Precompiler stuff?
I have no idea. But I'd like to be able to get mail in from a thread and be able to dynamically know where to send it back to without having to use a switch of MailPut(X) MailPut(Y), MailPut(Z), etc.
Anyone?
Oh nm. Really messed up things happen when you forget to osMailCreate() for all mailboxes.
It should have been obvious that they debugged as 0x0000000, that they were never initialized. Oddly enough ->id[0]=1; didn't cause an error.
The best bugs are the quickly found :)