Platform/ECM3532/M3/framework/serial_proto/src/serial_proto.c
/**
 * form and send command
 *
 * @param cmdVal command value
 * @param argCnt number of arguments
 * @param argCnt argArray argument arrary pointer
 * @return 0 on success, non-zero error code on failure
 *
 */
form and send command
@param cmdVal command value
@param argCnt number of arguments
@param argCnt argArray argument arrary pointer
@return 0 on success, non-zero error code on failure
form and send command @param cmdVal command value @param argCnt number of arguments @param argCnt argArray argument arrary pointer @return 0 on success non - zero error code on failure
int sendCmd(uint8_t cmdVal, uint8_t argCnt, uint8_t *argArray)
{
  uint8_t bufLen, cmdLen, i;
  uint8_t *buf, *cmdPtr;
  tPktHdr *Pkt;
  cmdLen =  1 + argCnt;
  bufLen = (sizeof(tPktHdr)) + cmdLen;
  buf = pvPortMalloc(bufLen);
  if (buf)
  {
    xSemaphoreTake(spDev.xSPLock, portMAX_DELAY);
    spDev.st = CMD_ST;
    Pkt = (tPktHdr *)buf;
    Pkt->sof = SOF;
    Pkt->ptype = CMD;
    Pkt->plen = cmdLen;
    cmdPtr = buf + sizeof(tPktHdr);
    cmdPtr[0] = cmdVal;
    for (i = 0; i < argCnt; i++)
      cmdPtr[i + 1] =  argArray[i];
    xportSend(buf, bufLen);
    spDev.st = DONE;
    xSemaphoreGive(spDev.xSPLock);
    vPortFree(buf);
  }
  return 0;
}
int sendCmd ( uint8_t cmdVal , uint8_t argCnt , uint8_t * argArray ) { uint8_t bufLen , cmdLen , i ; uint8_t * buf , * cmdPtr ; tPktHdr * Pkt ; cmdLen = 1 + argCnt ; bufLen = ( sizeof ( tPktHdr ) ) + cmdLen ; buf = pvPortMalloc ( bufLen ) ; if ( buf ) { xSemaphoreTake ( spDev . xSPLock , portMAX_DELAY ) ; spDev . st = CMD_ST ; Pkt = ( tPktHdr * ) buf ; Pkt -> sof = SOF ; Pkt -> ptype = CMD ; Pkt -> plen = cmdLen ; cmdPtr = buf + sizeof ( tPktHdr ) ; cmdPtr [ 0 ] = cmdVal ; for ( i = 0 ; i < argCnt ; i ++ ) cmdPtr [ i + 1 ] = argArray [ i ] ; xportSend ( buf , bufLen ) ; spDev . st = DONE ; xSemaphoreGive ( spDev . xSPLock ) ; vPortFree ( buf ) ; } return 0 ; }
form and send command
 @param cmdVal command value
 @param argCnt number of arguments
 @param argCnt argArray argument arrary pointer
 @return 0 on success, non-zero error code on failure
form and send command @param cmdVal command value @param argCnt number of arguments @param argCnt argArray argument arrary pointer @return 0 on success non - zero error code on failure