int16_t rsi_zigb_execute_cmd(uint8_t *descparam, uint8_t *payloadparam, uint16_t size_param)
{
  int16_t                                         retval = 0;
  rsi_zigb_uFrameDsc         uFrameDscFrame;
  uint8_t           *cmd_buff;
#ifdef RSI_DEBUG_PRINT
  RSI_DPRINT(RSI_PL14,"\nrsi_zigb_execute_cmd:\n");
#endif

  //! Build 16 bytes, send/receive command descriptor frame
  rsi_zigb_build_frame_descriptor(&uFrameDscFrame, descparam, size_param);

  cmd_buff = rsi_alloc_and_init_cmdbuff((uint8_t *)&uFrameDscFrame,payloadparam,size_param);

  if(rsi_send_usr_cmd(cmd_buff, GET_SEND_LENGTH(cmd_buff)) < 0)
  {
    retval = -2;
  }
  if(retval < 0)
  {
    printf("Unable to issue command\n");
  }

  //! Free the command buffer
  rsi_free(cmd_buff);

  return retval;
}
static void rsi_put(struct cache_head *item, struct cache_detail *cd)
{
	struct rsi *rsii = container_of(item, struct rsi, h);
	if (cache_put(item, cd)) {
		rsi_free(rsii);
		kfree(rsii);
	}
}
Exemplo n.º 3
0
int16_t rsi_frame_read(uint8_t *packet_buffer)
{
  /* Variables */
  rsi_linux_app_cb_t *linux_app_cbPtr = &rsi_linux_app_cb;
  pkt_struct_t *rspPtr = NULL;

  /* Length of the data to copy */
  int16_t length = 0;

  /* Pointer to the Packet file descriptor */
  uint8_t *descPtr    = NULL;

#ifdef RSI_DEBUG_PRINT
  int i;
#endif

  /* Do actual deque from the RX queue */
  pthread_mutex_lock(&linux_app_cbPtr->mutex1);
  rspPtr = rsi_dequeue_from_rcv_q();
  pthread_mutex_unlock(&linux_app_cbPtr->mutex1);

  /* Assign pointers to appropriate addresses */
  descPtr    = rspPtr->data + RSI_NL_HEAD_SIZE;

  /* Calculate length of the packet from the first two bytes of the frame descriptor */
#ifdef RSI_LITTLE_ENDIAN
  length = *(int16_t*)descPtr & 0x0fff;
#else
  length = rsi_bytes2R_to_uint16(descPtr);
#endif
  length += RSI_FRAME_DESC_LEN;

  /* Debug: Print the length & contents of the packet */
#ifdef RSI_DEBUG_PRINT
  RSI_DPRINT(RSI_PL0,"RX Len of the packet: %d\n", length);
  for (i=0; i<length; i++) {
      RSI_DPRINT (RSI_PL0, "0x%x ", descPtr[i]);
      if ((i % 16 == 0) && (i != 0)) {
          RSI_DPRINT(RSI_PL0, "\n");
      }
  }
  RSI_DPRINT(RSI_PL0, "\n");
#endif

  memset(packet_buffer, 0, length);
  memcpy(packet_buffer, descPtr, length);

  rsi_free(rspPtr);

  /* Return success */
  return RSI_ZB_SUCCESS;
}