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.

get_time example error code -22



Hi,


I'm trying to get the get_time example working on a MCU connected to a CC3100 via SPI interface.  The test runs fine, connecting to the AP and getting an IP address, up until the call to getSNTPTime() which fails on the call to sl_Bind with a return value of -22.  Is there a list of return code somewhere that I can check to see what the significance of this value, if it has any meaning at all?  I've used the same board to run the Simplelink Studio get_time example and that runs fine but I can't determine why it is failing for the MCU test.


Regards,

Hugh

  • The socket.h file has the error codes

    #define SL_EINVAL (-22) /* Invalid argument */

    Looks like you are passing an incorrect parameter, I would be looking at the changes you have made to #defines

    Glenn.
  • Hi Hugh,

    As Glenn suggested, the parameters to bind could be wrong.
    Also, are you using the sample porting already available in the SDK (i.e, MCUs supported in the SDK)? Have you made any changes to the host driver?

    Regards,
    Raghavendra
  • I've ported the driver to a new MCU but haven't made any changes to the host driver apart from user.h and the board support/SPI code. The parameters to slBind are identical to those in the Simplelink Studio get_time example (sockID=0, addrsize=16, LocalAddr.sin_family=SL_AF_INET, LocalAddr.sin_port=0, LocalAddr.sin_addr.s_addr=0).

    I've checked the SPI data transferred for this command and the simplelink test sends
    21 43 34 12 04 94 0C 00 00 00 00 20 00 00 CC CC 00 00 00 00
    whereas the MCU test sends
    21 43 34 12 04 95 0C 00 00 00 00 20 00 00 1B 70 00 00 00 00

    I'm unsure what's causing this difference. What [parameter(s)] do the different bytes relate to?
  • Hugh,

    Where are you creating the socket? Did you port the printf function as well?

    Regards,
    Aaron
  • Hi,

    The running code is the unchanged get_time example of SDK 1.1.0 so you can check that for reference to where the socket is created, etc. I'm using a native implementation of printf for the host MCU that outputs to a UART. I've since gotten the test working but it still fails sometimes .. seems to be related to the SPI baud rate and/or the delay before and after CS_ASSERT / CS_DEASSERT. Have you any insight into decoding the command the host MCU sends in the failing case? Or is there an upper limit to the delay between chip select toggling and the transmission/cessation of SPI data transfer? I was using a delay of 1ms but changed this to 2us, which seemed to help.


    Regards,
    Hugh
  • Hugh,

    I was experimenting with converting the get_time example to use a nonblocking socket, and I had a similar problem with the get_time example failing with error -22 at the sl_Bind call. Double-checked the sl_Bind parameters, and they were all OK.

    I had placed a CLI_Write call between sl_SendTo and sl_Bind; with that CLI_Write, sl_Bind always failed with -22. On a hunch I commented out the CLI_Write. Without the CLI_Write, the sl_Bind always succeeded. Why I can't say, but it doesn't seem right.

    It seemed to me that there was no reason why the socket couldn't be bound BEFORE the sl_Send.  I tried that and it works fine -- I call sl_Bind prior to sl_Send and get no error, even with my CLI_Write between sl_SendTo and sl_RecvFrom.

    I can't explain why Bind then SendTo works and vice versa fails -- maybe the TI folks will weigh in with an informed opinion.

    All the best,

    Jeff

  • Hi Jeff,

    Make sure you are using both the latest SDK and service pack.. It could be your service pack and host driver are mismatched.

    -Aaron