Revision 341cc329 core/src/aos_rtcan.c

View differences:

core/src/aos_rtcan.c
30 30
#define HRTMSG 00
31 31
#define SRTMSG 01
32 32
#define NRTMSG 11
33
#define SLEEPTIME 20
33 34

  
34 35
static THD_WORKING_AREA(myThreadWorkingArea, 128);
35 36

  
......
67 68
        }else{
68 69
            prevElem->next = msg;
69 70
            msgqueue->tail = msg;
71
            msgqueue->size++;
70 72
            return true;
71 73
        }
72 74
    }
......
102 104
  if(!msgqueueEmpty(msgqueue)){
103 105
      rtcan_msg_t *elem = msgqueue->head;
104 106
      msgqueue->head = elem->next;
107
      msgqueue->size--;
105 108
      return elem;
106 109
  }
107 110
  return NULL;
......
120 123

  
121 124
// Handling Message Queues
122 125

  
123
bool enqueueMsg(uint8_t *payload, uint8_t msgType, systime_t deadline){
126
bool enqueueMsg(uint8_t *payload, uint8_t msgType, aos_timestamp_t deadline){
124 127
  static rtcan_msg_t msg;
125 128
  msg.payload = payload;
126 129
  msg.msgType = msgType;
......
135 138
  return false;
136 139
}
137 140

  
141
u_int32_t createId(rtcan_msg_t *msg, uint8_t msgType){
142
    // first 6 bit laxity
143
    // 6-21 id
144
    // 21-29 fragment
145
    u_int32_t id = 0;
146
    aos_timestamp_t uptime;
147
    aosSysGetUptime(&uptime);
148

  
149
   uint32_t uptimeMcs = (uint32_t)(uptime / MICROSECONDS_PER_DAY);
150

  
151

  
152
}
153

  
138 154

  
139 155
/**
140 156
 * @brief schedule rtcan messages into mailboxes
......
146 162
  int nextSlot; // set by while loop from calendar
147 163

  
148 164
  while (true){
165
    // send Frame of Timeslot
149 166
    // iterate over calendar(bitmask)
150 167
    rtcan_msg_t *nextMsg;
151
    chThdSleepMilliseconds( 20 );
168
    chThdSleepMilliseconds( SLEEPTIME );
152 169
    if(nextSlot == 1){
153 170
      nextMsg = popRTCanMsg(&hrtQueue);
154 171
    }else{
......
158 175
        nextMsg = popRTCanMsg(&nrtQueue);
159 176
      }
160 177
    }
161
    // Take next element from queue
162
    // create frame
163
    // place it in buffer to be sent in next time slot
164
    chThdSleepMilliseconds( 20 );
178
    if(nextMsg != NULL){
179
      // create frame
180
      // frame needs id, payload(later) and ___
181
      // place it in Mailbox to be sent in next time slot
182
    }
183
     // maybe send empty message if no message to reduce jitter????
184
    chThdSleepMilliseconds( SLEEPTIME );
165 185
  }
166 186

  
167 187
  return 0;

Also available in: Unified diff