This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Unlinked Peer to Peer communication using IOCTL calls

Other Parts Discussed in Thread: CC-DEBUGGER, SIMPLICITI

Hi everyone,

                              I'm facing a problem that some/most of you might already have overcome.

Hardware: CC1110 EVK (Four) and CC-Debugger (Two)

Software: SimpliciTI 1.1.1 and IAR workbench

Basically, I want to communicate between two unlinked devices using IOCTL calls. More specifically, I've tried using SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_WRITE, voidWritePointer) for transmission and

SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_READ, voidReadPointer) for reading. Mind you that I've initialized the voidWritePointer with the necessary fields like address of the device I want to send the message to, port on which I wish to send, length and message. Initialized the voidReadPointer with address of the device I'm expecting the message from, port on which the sending device is sending the message on.

I have a packet sniffer so I can see that transmission of the packet with the payload is happening as it should, with the correct destination address. But keeping watch on the the reading device with breakpoints, I always end up getting SMPL_NO_FRAME as the return of the SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_READ, voidReadPointer) call.

These calls work fine with the user broadcast address (0x3F) but I want to use a different port address. I've tried with port addresses 0x20 and 0x10 but both return the SMPL_NO_FRAME.

Digging into the SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_READ) I saw that it uses the nwk_rawReceive() which in turn calls the nwk_retrieveFrame(). By using breakpoints and stepping, I made the following observations:

  • The network address that I specified in the SMPL_Ioctl(IOCTL_ACT_READ) call, meaning the address of the device I want to read from, is not regarded anywhere. ONLY the port address is assigned in the nwk_rawReceive().
  • Inside nwk_retrieveFrame(), the function nwk_QfindOldest() is called to see if there is any frame in the queue for the specified port. This where the function throws back (returns) the SMPL_NOFRAME

I feel that I am missing something very basic and hope that somebody might take the liberty to point it out.

Thanks!

Yash Darad

 

EDIT: I realized that I had not attached the initialization routines.

snippet from receiving routine


uint8_t rxMsg[MAX_APP_PAYLOAD], len, hopCount;
  uint8_t txMsg[MAX_APP_PAYLOAD];
 
  smplStatus_t status;
 
  addr_t devAddr;
  addr_t *pDevAddr;
  pDevAddr = &devAddr;
 
  void *rxRawMsg;
  
  ioctlRawReceive_t* pRxReqd;
  ioctlRawReceive_t rxReqd;
  pRxReqd = &rxReqd;
 
  uint8_t *pLen;
  pLen = &len;
 
  uint8_t *pHopCount;
  pHopCount = &hopCount;
   
  devAddr.addr[0] = 0x79;    //Address of device I want to listen from
  devAddr.addr[1] = 0x56;
  devAddr.addr[2] = 0x34;
  devAddr.addr[3] = 0x12;
 
  pRxReqd->addr = &devAddr;
  //pRxReqd->port = SMPL_PORT_NWK_BCAST;
  pRxReqd->port = 0x10;

 
 
  SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0);  //Turn on Radio
 
  NWK_DELAY(100); //wait for sometime...
   
  while(1)
  {
    SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0);  //Turn on Radio
 
    NWK_DELAY(100); //wait for sometime...
   
      rxRawMsg = (void*)pRxReqd;
     
      status = SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_READ, rxRawMsg);

}

 

Snippet from Transmission routine

uint8_t rxMsg[MAX_APP_PAYLOAD], len, hopCount, i = 0, j = 5;
  uint8_t txMsg[MAX_APP_PAYLOAD];
   
 
  ioctlRawSend_t txReqd;
  ioctlRawSend_t *pTxReqd;
  pTxReqd = &txReqd;
 
  addr_t *pDevAddr;
  addr_t devAddr;
 
  pDevAddr = &devAddr;
 
  void *pVoidObject;
 
 
  SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0);  //Turn on Radio
 
  NWK_DELAY(100); //wait for sometime...
 
  while(1)
  {
      txMsg[0] = JOIN_ME;
      
      devAddr.addr[0] = 0x97;           //Address of device I want to send message to
      devAddr.addr[1] = 0x56;
      devAddr.addr[2] = 0x34;
      devAddr.addr[3] = 0x12;
     
      pTxReqd->addr = &devAddr;
      pTxReqd->port = 0x10;
      pTxReqd->msg = txMsg;
      pTxReqd->len = 1;
 
      pVoidObject = pTxReqd;
     
      //pTxReqd->port = SMPL_PORT_NWK_BCAST; //Not sure if port number is required...
     
   
      SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_WRITE, pVoidObject);

}

 

Ideas will be much appreciated.

  • Hello.

    Your observations are correct. Basically the raw I/O scheme will not work when the port specified is in the user (application) part of the port namespace. Any frame that specifies a port in the user namespace will be rejected if a valid connection does not exist when the frame is received. This filtering is done in nwk_frame.c:dispatchFrame(). The reasons for the raw I/O not working in this case have more to do with how the stack evolved during development rather than as a specific design goal. But the bottom line is that what your are trying to do will not work.

    Is there some specific Usse Case you trying to satisfy that can't be accomplished with either the user broadcast port or establishing a valid connection?

    Hope this helps.

    lfriedman

     

  • Hi lfriedman,

                          Thanks for taking the time to read through that longish post.  I had nearly lost hope... =P Also thanks for pointing out that what I was attempting was not feasible with the given stack.

    What I wanted to do was to see if there are any devices in the network. If there are multiple devices, then I should have the ability to link to a specific device. In order to link to that specific device, I wanted to share the link token between the two devices. Hence the need for direct messaging between unlinked devices...

    Well, turns out that my understanding of the "user broadcast" scheme was not totally correct. I was under the impression that as long as the PORT was 0x3F, every device would pick it up. By changing the destination address from 0xFFFFFFFF to whichever one I wanted, I could communicate with the device (without linking) on the 0x3F port!

    So now I can exchange link tokens with the device I want and then process with a "private" linking procedure. At least in theory. I'm yet to try it. Will post the results...

    Thanks, once again!

    Yash Darad