37 #include "esos_pc_stdio.h"
45 #include <sys/select.h>
55 void reverseString(
char *psz_s1,
char *psz_s2);
56 uint32_t randomNumInRange(uint32_t u32_lo, uint32_t u32_hi);
64 static uint8_t psz_CRNL[3]= {0x0D, 0x0A, 0};
68 uint32_t u32_myT1Count = 0;
72 struct stTask* pst_MyTasks[3];
85 __esos_tmrSvcsExecute();
105 uint32_t randomNumInRange(uint32_t u32_lo, uint32_t u32_hi) {
106 uint32_t u32_d1, u32_d2, u32_d4, u32_ret;
111 u32_ret = u32_lo + u32_d4;
112 if (u32_ret <= u32_hi)
return u32_ret;
116 u32_ret = u32_lo + u32_d2;
117 if (u32_ret <= u32_hi)
return u32_ret;
120 u32_ret = u32_lo + u32_d1;
121 if (u32_ret <= u32_hi)
return u32_ret;
149 static MAILMESSAGE st_Message;
160 ESOS_TASK_MAKE_MSG_UINT8(st_Message, u8_cnt);
169 printf(
"C0 sending MESSAGE %d\n", u8_cnt);
170 ESOS_TASK_SEND_MESSAGE(hTask, &st_Message);
172 printf(
"C0 doing useful work instead of mailing. Discarding MESSAGE %d.\n", u8_cnt );
176 if (u8_cnt>50) u8_cnt=0;
191 static MAILMESSAGE st_Message;
198 ESOS_TASK_MAKE_MSG_UINT8(st_Message, u8_cnt);
204 if ( (u32_rnd % 4) == 0 ) {
205 st_Message.u8_flags |= ESOS_MAILMESSAGE_REQUEST_ACK;
206 printf(
"C1 sending MESSAGE with ACK request %d\n", u8_cnt);
207 ESOS_TASK_SEND_MESSAGE_WAIT_DELIVERY(hTask, &st_Message);
209 printf(
"C1 sending MESSAGE %d\n", u8_cnt );
210 ESOS_TASK_SEND_MESSAGE(hTask, &st_Message);
214 if (u8_cnt>150) u8_cnt=100;
230 static MAILMESSAGE stMsg;
250 __esos_ReadMailMessage(__pstSelf, &stMsg );
251 printf(
"Got a message from ");
252 if (ESOS_IS_TASK_SENDER( hSenderC0, stMsg)) {
254 }
else if (ESOS_IS_TASK_SENDER( hSenderC1, stMsg)) {
259 printf (
" containing %d enroute time = %d ms\n", stMsg.au8_Contents[0],
esos_GetSystemTick()-stMsg.u32_Postmark );
305 __esos_unsafe_PutString( HELLO_MSG );