AnsweredAssumed Answered

Is there a working example of the creation of a TCP socket on a TWR P1025 QorIQ MPU Tower System Module?

Question asked by Clive Stokes on Jun 10, 2013
Latest reply on Jun 10, 2013 by Clive Stokes

I wish to run an an application that acts as a TCP Client to an IP Camera under MQX 3.8 on the TWR P1025 QorIQ MPU Tower System Module - the application having previously worked on the same board under QNX.  I made the necessary code changes to get the code to compile but found it crashed when it encounters the socket command. I then minimised the code to isolate the socket command:


#include <mqx.h>
#include <bsp.h>
#include <rtcs.h>
#include <string.h>
#include <posix.h>
#include "config.h"


void main_task(uint_32);


#define TCP_CLIENT_PORT               50501


** MQX initialisation information


const TASK_TEMPLATE_STRUCT  MQX_template_list[] =
   /* Task Index,   Function,   Stack,  Priority,   Name,    Attributes,          Param, Time Slice */
   { 1,             main_task,  6500,   8,          "Main",  MQX_AUTO_START_TASK, 0,     0 },
   { 0 }


void main_task(uint_32 temp) {


    unsigned long sockfd = 0;
    struct sockaddr_in  client;

    /* create socket */
    sockfd = socket(PF_INET, SOCK_STREAM, 0 );
    if (sockfd == RTCS_SOCKET_ERROR)
        printf("Error creating socket %d\n",sockfd);


    printf("Created Socket %d\n",sockfd);


I then stepped through the disassembly of the socket command:



04016880:   stwu rsp,-32(rsp)

04016884:   mflr r0

04016888:   li r3,1

0401688c:   li r6,0

04016890:   li r7,0

04016894:   li r8,0

04016898:   stw r0,36(rsp)

0401689c:   stw r31,28(rsp)

040168a0:   mr r31,r4

040168a4:   mr r5,r31

040168a8:   lis r4,512

040168ac:   bl RTCS_log (0x40165b8); 0x040165B8

040168b0:   li r3,0           <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

040168b4:   bl _task_get_td (0x400d8c4); 0x0400D8C4

040168b8:   mr r4,r3

040168bc:   mr r3,r31

and found it to crash at the instruction indicated.

Have I failed to initialise something? Is there an example of the use of a TCP Client on the TWR P1025 QorIQ MPU Tower System Module?