Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - echel0n

Pages: [1] 2 3
1
µTasker general / Re: Newbie's firsttime with uTasker
« on: March 05, 2009, 05:19:54 AM »
Ok i've changed the following code and things seemed to have sped up a bit but it's like it comes in bursts but just isn't a steady enough speed to keep communication with my device going.

Code: [Select]
static int fnReadIrd(unsigned char * buf)
{
    static int iRxReceived = 0;                                          // the number of byte received (until now)
    static int iExpectedbytes = 0;
    unsigned char ucInputMessage;                                        // reserve space for receiving messages

iRxReceived = iExpectedbytes = 0;
    while (fnRead(SerialPortID, &ucInputMessage, 1) != 0) {              // read each presently available input byte
if (iRxReceived == 0) {                                            // searching for sync byte
          if (ucInputMessage != 0x21) {
              continue;                                                  // still not found sync byte
          }
          iRxReceived = 1;                                               // synchronised
          buf[0] = ucInputMessage;
      }
      else {
          if (iRxReceived >= RX_BUFFER_SIZE) {                           // protect buffer overrun on invalid frames
              iRxReceived = iExpectedbytes = 0;                          // go back to sync hunt mode
              continue;
          }
          buf[iRxReceived++] = ucInputMessage;                           // collect message content
          if (iRxReceived == 3) {                                        // the expected length is now known
              iExpectedbytes = (ucInputMessage + 4);                     // note the expected length
          }
          if (iRxReceived == iExpectedbytes) {                           // the complete message has now been collected
              return iExpectedbytes;                                     // inform of the frame length so that it can be processed
          }
      }

    }
    return -1;                                                           // frame not yet ready
}

Not sure if I placed the iRxReceived = iExpectedbytes = 0; in the correct place but it seems to work better now.

Now I'm not sure if buffered TCP would work since the device needs to make a request and then get a response before it can make another request or it'll just timeout and go back to the very first request it made.

2
µTasker general / Re: Newbie's firsttime with uTasker
« on: March 05, 2009, 04:23:05 AM »
Ok let me explain my self a little better on whats really slow.

I can send the data to the server and get a response back right away it's the time after that I wait for it to process the next request from the uart thats slow.
See the device that is sending requests to my ARM7 device responds right away but if not answered right away it'll timeout so what needs to happen is after the response comes back from the server and gets sent out via the uart to my other device the task needs to restart and get data from the uart again right away.

3
µTasker general / Re: Newbie's firsttime with uTasker
« on: March 05, 2009, 03:18:01 AM »
Ok i'm now able to send and receive the data and send it out of my uart but I notice that it's all running rather slow like it doesn't try and get the next request from the uart after I send my response I got from ethernet out via the uart.

Anyway to rectify this to go quicker ?

4
µTasker general / Re: Newbie's firsttime with uTasker
« on: March 05, 2009, 01:32:16 AM »
Ok here's a update on all the code I have so far.
It appears to send data but once it gets to the 2nd time around it gives a exception error in vb.net

Code: [Select]
#include "config.h"
#include "IKSClient.h"

#define OWN_TASK TASK_IKS_CLIENT

#define INITIALISATION       0
#define ACTIVE               1

// TCP Settings
int connected = 0;
int busy = 0;
#define IKS_SERVER_PORT      8000
static USOCKET iks_client_socket;
static unsigned char iks_server_ip[IPV4_LENGTH] = {192, 168, 1, 69};
#define MAX_DATA_LEN 100
typedef struct stTCP_MESSAGE
{
    TCP_HEADER     tTCP_Header;                    // reserve header space
    unsigned char  ucTCP_Message[MAX_DATA_LEN];    // data payload space
} TCP_MESSAGE;
static TCP_MESSAGE IKSData;

// Serial Port Settings
int iSerialRxLenth = 0;
static unsigned char ucSerialInput[RX_BUFFER_SIZE];
QUEUE_HANDLE SerialPortID = 0;

static int fnIKSListener(USOCKET Socket, unsigned char ucEvent, unsigned char *ucIp_Data, unsigned short usPortLen)
{
    switch (ucEvent) {
case TCP_EVENT_CONNECTED:
connected = 1;
memcpy(IKSData.ucTCP_Message,ucSerialInput,iSerialRxLenth);
if(fnSendTCP(iks_client_socket, (unsigned char *)&IKSData.tTCP_Header, iSerialRxLenth, TCP_FLAG_PUSH) > 0)
return APP_SENT_DATA;
break;
    case TCP_EVENT_ARP_RESOLUTION_FAILED:
        break;
case TCP_EVENT_REGENERATE:
memcpy(IKSData.ucTCP_Message,ucSerialInput,iSerialRxLenth);
if(fnSendTCP(iks_client_socket, (unsigned char *)&IKSData.tTCP_Header, iSerialRxLenth, TCP_FLAG_PUSH) > 0)
return APP_SENT_DATA;
break;
    case TCP_EVENT_DATA:
busy = 0;
        break;
    case TCP_EVENT_CLOSE:
    case TCP_EVENT_CLOSED:
connected = 0;
        break;
case TCP_EVENT_ACK:
connected = 1;
uTaskerStateChange(OWN_TASK, UTASKER_ACTIVATE);
break;
    case TCP_EVENT_ABORT:
fnTCP_Connect(iks_client_socket, iks_server_ip, IKS_SERVER_PORT, 0, 0);
        break;
    }
    return APP_ACCEPT;
}

static int fnReadIrd(unsigned char * buf)
{
    static int iRxReceived = 0;                                          // the number of byte received (until now)
    static int iExpectedbytes = 0;
    unsigned char ucInputMessage;                                        // reserve space for receiving messages

    while (fnRead(SerialPortID, &ucInputMessage, 1) != 0) {              // read each presently available input byte
if (iRxReceived == 0) {                                            // searching for sync byte
          if (ucInputMessage != 0x21) {
              continue;                                                  // still not found sync byte
          }
          iRxReceived = 1;                                               // synchronised
          buf[0] = ucInputMessage;
      }
      else {
          if (iRxReceived >= RX_BUFFER_SIZE) {                           // protect buffer overrun on invalid frames
              iRxReceived = iExpectedbytes = 0;                          // go back to sync hunt mode
              continue;
          }
          buf[iRxReceived++] = ucInputMessage;                           // collect message content
          if (iRxReceived == 3) {                                        // the expected length is now known
              iExpectedbytes = (ucInputMessage + 4);                     // note the expected length
          }
          if (iRxReceived == iExpectedbytes) {                           // the complete message has now been collected
              return iExpectedbytes;                                     // inform of the frame length so that it can be processed
          }
      }

    }
    return -1;                                                           // frame not yet ready
}

// This task is started once to initialise the interface and then for each received character
//
extern void fnIKSClient(TTASKTABLE *ptrTaskTable)
{
    QUEUE_HANDLE        PortIDInternal = ptrTaskTable->TaskID;           // queue ID for task input

    if (!SerialPortID) {                                                 // configure interfaces on initialisation
        SerialPortID = fnSetNewSerialMode(FOR_I_O);
iks_client_socket = fnGetTCP_Socket(TOS_MINIMISE_DELAY, TCP_DEFAULT_TIMEOUT, fnIKSListener);
    }

    if (connected >= 2) {  // TCP transmission is busy so wait - queue all UART rx data in UART buffer in the meantime
        return;
    }

    while ((iSerialRxLenth = fnReadIrd(ucSerialInput)) != -1) {             // collect the data until ready
memcpy(IKSData.ucTCP_Message,ucSerialInput,iSerialRxLenth);

if(!connected){
fnTCP_Connect(iks_client_socket, iks_server_ip, IKS_SERVER_PORT, 0, 0);
connected = 2;
} else {
fnSendTCP(iks_client_socket, (unsigned char *)&IKSData.tTCP_Header, iSerialRxLenth, TCP_FLAG_PUSH);
connected = 3;
}
break;
}
    // else quit - we return on further input
}



// After changes, we set up the new serial configuration
// (moved from application.c to here) - in application.s #undef SERIAL_INTERFACE added to remove its control of the serial interface
extern QUEUE_HANDLE fnSetNewSerialMode(unsigned char ucDriverMode)
{
    TTYTABLE tInterfaceParameters;                                       // table for passing information to driver
    tInterfaceParameters.Channel = DEMO_UART;                            // set UART channel for serial use
    tInterfaceParameters.ucSpeed = temp_pars->temp_parameters.ucSerialSpeed; // baud rate
    tInterfaceParameters.Rx_tx_sizes.RxQueueSize = RX_BUFFER_SIZE;       // input buffer size
    tInterfaceParameters.Rx_tx_sizes.TxQueueSize = TX_BUFFER_SIZE;       // output buffer size
    tInterfaceParameters.Task_to_wake = OWN_TASK;                        // wake self when messages have been received
    #ifdef SUPPORT_FLOW_HIGH_LOW
    tInterfaceParameters.ucFlowHighWater = temp_pars->temp_parameters.ucFlowHigh;// set the flow control high and low water levels in %
    tInterfaceParameters.ucFlowLowWater = temp_pars->temp_parameters.ucFlowLow;
    #endif
    tInterfaceParameters.usConfig = temp_pars->temp_parameters.usSerialMode;
    #ifdef SERIAL_SUPPORT_DMA
    tInterfaceParameters.ucDMAConfig = UART_TX_DMA;                      // activate DMA on transmission
    #endif
    if ((SerialPortID = fnOpen( TYPE_TTY, ucDriverMode, &tInterfaceParameters )) != 0) { // open or change the channel with defined configurations (initially inactive)
       fnDriver( SerialPortID, ( TX_ON | RX_ON ), 0 );                  // enable rx and tx
    }
    return SerialPortID;
}

BTW I appreciate all the time and effort your putting into this for me and others.
Thanks!!!

5
µTasker general / Re: Newbie's firsttime with uTasker
« on: March 05, 2009, 12:27:54 AM »
Will this work ???

Code: [Select]
extern void fnIKSClient(TTASKTABLE *ptrTaskTable)
{
    QUEUE_HANDLE        PortIDInternal = ptrTaskTable->TaskID;           // queue ID for task input

    if (!SerialPortID) {                                                 // configure interfaces on initialisation
        SerialPortID = fnSetNewSerialMode(FOR_I_O);
    }

while((iks_client_socket = fnGetTCP_Socket(TOS_MINIMISE_DELAY, TCP_DEFAULT_TIMEOUT, fnIKSListener)) < 0);

    while ((iSerialRxLenth = fnReadIrd(ucSerialInput)) != -1) {             // collect the data until ready
if(!connected){
fnTCP_Connect(iks_client_socket, iks_server_ip, IKS_SERVER_PORT, 0, 0);
}

//memcpy(IKSData.ucTCP_Message,ucSerialInput,iSerialRxLenth);
//fnSendTCP(iks_client_socket, (unsigned char *)&IKSData.tTCP_Header, iSerialRxLenth, TCP_FLAG_PUSH);
// Wait for data to be sent


        // data ready
        // handle it here
    }
    // else quit - we return on further input
}

6
µTasker general / Re: Newbie's firsttime with uTasker
« on: March 04, 2009, 07:40:11 PM »
Ok via wireshark I see my data being sent but the packet length is set to 1 insteaf of 5 ....
This doesn't make sense.

Transmission Control Protocol, Src Port: 49744 (49744), Dst Port: irdmi (8000), Seq: 0, Len: 1
Options: (4 bytes)
Data (1 byte)

7
µTasker general / Re: Newbie's firsttime with uTasker
« on: March 04, 2009, 07:13:35 PM »
Checksum: 0x83f1 [incorrect, should be 0x3791 (maybe caused by "TCP checksum offload"?)]

Thats what I got for 30 in wireshark.

Here's my revised code
Code: [Select]
#include "config.h"
#include "IKSClient.h"

#define OWN_TASK TASK_IKS_CLIENT

#define INITIALISATION       0
#define ACTIVE               1

// TCP Settings
#define IKS_SERVER_PORT      8000
static USOCKET iks_client_socket;
static unsigned char iks_server_ip[IPV4_LENGTH] = {192, 168, 1, 69};

#define MAX_DATA_LEN 100
typedef struct stTCP_MESSAGE
{
    TCP_HEADER     tTCP_Header;                    // reserve header space
    unsigned char  ucTCP_Message[MAX_DATA_LEN];    // data payload space
} TCP_MESSAGE;

// Serial Port Settings
QUEUE_HANDLE SerialPortID = 0;

static int fnIKSListener(USOCKET Socket, unsigned char ucEvent, unsigned char *ucIp_Data, unsigned short usPortLen)
{
    switch (ucEvent) {
    case TCP_EVENT_ARP_RESOLUTION_FAILED:
        break;
    case TCP_EVENT_DATA:                                                 // a time server sends the time in seconds from 0:0:0 1900 and terminates
        //ulPresentTime = *ucIp_Data++;
        //uTaskerMonoTimer( OWN_TASK, (DELAY_LIMIT)(1*SEC), E_SECOND_TICK );
        break;
    case TCP_EVENT_CLOSE:
    case TCP_EVENT_CLOSED:
        break;
        // If remote server closed before we received the time, try next
    case TCP_EVENT_ABORT:                                              // no connection was established
        //if (ucTimeServerTry < NUMBER_OF_TIME_SERVERS) {
        //    fnTCP_Connect(TIME_TCP_socket, (unsigned char *)&ucTimeServers[ucTimeServerTry++], TIME_PORT, 0, 0); // {15} ucTimeServerTry incremented after use and not before
        //}
        break;

    }
    return APP_ACCEPT;
}

static int fnReadIrd(unsigned char * buf)
{
    static int iRxReceived = 0;                                          // the number of byte received (until now)
    static int iExpectedbytes = 0;
    unsigned char ucInputMessage;                                        // reserve space for receiving messages

    while (fnRead(SerialPortID, &ucInputMessage, 1) != 0) {              // read each presently available input byte
if (iRxReceived == 0) {                                            // searching for sync byte
          if (ucInputMessage != 0x21) {
              continue;                                                  // still not found sync byte
          }
          iRxReceived = 1;                                               // synchronised
          buf[0] = ucInputMessage;
      }
      else {
          if (iRxReceived >= RX_BUFFER_SIZE) {                           // protect buffer overrun on invalid frames
              iRxReceived = iExpectedbytes = 0;                          // go back to sync hunt mode
              continue;
          }
          buf[iRxReceived++] = ucInputMessage;                           // collect message content
          if (iRxReceived == 3) {                                        // the expected length is now known
              iExpectedbytes = (ucInputMessage + 4);                     // note the expected length
          }
          if (iRxReceived == iExpectedbytes) {                           // the complete message has now been collected
              return iExpectedbytes;                                     // inform of the frame length so that it can be processed
          }
      }

    }
    return -1;                                                           // frame not yet ready
}

// This task is started once to initialise the interface and then for each received character
//
extern void fnIKSClient(TTASKTABLE *ptrTaskTable)
{
static TCP_MESSAGE IKSData;
    static unsigned char ucSerialInput[RX_BUFFER_SIZE];                  // static buffer for collecting UART data
    QUEUE_HANDLE        PortIDInternal = ptrTaskTable->TaskID;           // queue ID for task input
    int iSerialRxLenth = 0;                                              // length of collected UART data

    if (!SerialPortID) {                                                 // configure interfaces on initialisation
        SerialPortID = fnSetNewSerialMode(FOR_I_O);
    }

    while ((iSerialRxLenth = fnReadIrd(ucSerialInput)) != -1) {             // collect the data until ready
if ((iks_client_socket = fnGetTCP_Socket(TOS_MINIMISE_DELAY, TCP_DEFAULT_TIMEOUT, fnIKSListener)) >= 0) {
fnTCP_Connect(iks_client_socket, iks_server_ip, IKS_SERVER_PORT, 0, 0);
}

memcpy(IKSData.ucTCP_Message,ucSerialInput,iSerialRxLenth);
if(fnSendTCP(iks_client_socket, (unsigned char *)&IKSData.tTCP_Header, iSerialRxLenth, TCP_FLAG_PUSH) >0) {
//successfull
}
        // data ready
        // handle it here
    }
    // else quit - we return on further input
}



// After changes, we set up the new serial configuration
// (moved from application.c to here) - in application.s #undef SERIAL_INTERFACE added to remove its control of the serial interface
extern QUEUE_HANDLE fnSetNewSerialMode(unsigned char ucDriverMode)
{
    TTYTABLE tInterfaceParameters;                                       // table for passing information to driver
    tInterfaceParameters.Channel = DEMO_UART;                            // set UART channel for serial use
    tInterfaceParameters.ucSpeed = temp_pars->temp_parameters.ucSerialSpeed; // baud rate
    tInterfaceParameters.Rx_tx_sizes.RxQueueSize = RX_BUFFER_SIZE;       // input buffer size
    tInterfaceParameters.Rx_tx_sizes.TxQueueSize = TX_BUFFER_SIZE;       // output buffer size
    tInterfaceParameters.Task_to_wake = OWN_TASK;                        // wake self when messages have been received
    #ifdef SUPPORT_FLOW_HIGH_LOW
    tInterfaceParameters.ucFlowHighWater = temp_pars->temp_parameters.ucFlowHigh;// set the flow control high and low water levels in %
    tInterfaceParameters.ucFlowLowWater = temp_pars->temp_parameters.ucFlowLow;
    #endif
    tInterfaceParameters.usConfig = temp_pars->temp_parameters.usSerialMode;
    #ifdef SERIAL_SUPPORT_DMA
    tInterfaceParameters.ucDMAConfig = UART_TX_DMA;                      // activate DMA on transmission
    #endif
    if ((SerialPortID = fnOpen( TYPE_TTY, ucDriverMode, &tInterfaceParameters )) != 0) { // open or change the channel with defined configurations (initially inactive)
       fnDriver( SerialPortID, ( TX_ON | RX_ON ), 0 );                  // enable rx and tx
    }
    return SerialPortID;
}

8
µTasker general / Re: Newbie's firsttime with uTasker
« on: March 04, 2009, 06:44:41 PM »
Ok it seems to be doing better now, I can actually ping it and I see my server saying utasker connected to it but still got issues.

This happens when utasker trys to connect to my pc server.
30   125.501740   192.168.1.69   192.168.1.65   TCP   irdmi > 49744 [RST, ACK] Seq=1 Ack=1 Win=0 [TCP CHECKSUM INCORRECT] Len=0

This happens when my utasker sends data to my pc server.
35   154.460465   192.168.1.65   192.168.1.69   TCP   [TCP Port numbers reused] 49744 > irdmi [SYN] Seq=0 Win=1460 Len=0 MSS=1460
36   154.460537   192.168.1.69   192.168.1.65   TCP   irdmi > 49744 [SYN, ACK] Seq=0 Ack=1 Win=8192 Len=0 MSS=1460
37   154.461381   192.168.1.65   192.168.1.69   TCP   49744 > irdmi [ACK] Seq=1 Ack=1 Win=1460 Len=0

The length of the packet we are trying to send should be 5

Here's my tcp code.
Code: [Select]
    while ((iSerialRxLenth = fnReadIrd(ucSerialInput)) != -1) {             // collect the data until ready
if ((iks_client_socket = fnGetTCP_Socket(TOS_MINIMISE_DELAY, TCP_DEFAULT_TIMEOUT, fnIKSListener)) >= 0) {
fnTCP_Connect(iks_client_socket, iks_server_ip, IKS_SERVER_PORT, 0, 0);
}

memcpy(IKSData.ucTCP_Message,ucSerialInput,iSerialRxLenth);
fnSendTCP(iks_client_socket, (unsigned char *)&IKSData, iSerialRxLenth, TCP_FLAG_PUSH);
        // data ready
        // handle it here
    }

9
µTasker general / Re: Newbie's firsttime with uTasker
« on: March 04, 2009, 05:57:24 PM »
Is there anything I should know about using the simulator and sending TCP data to my server on my pc cause no matter what I try it doesn't seem to ever send the data but I'm fairly sure the code is correct in my uTasker project.

??

10
µTasker general / Re: Newbie's firsttime with uTasker
« on: March 03, 2009, 11:54:50 PM »
Ok I understand what your saying and I did change vb.net to show hex instead of dec and now ucInputMessage shows the correct data and 0x21 gets matched but that doesn't explain why when testing via crossworks debugging that 0x21 was never matched nor was there any data ever put into ucInputMessage as far as I could tell.

11
µTasker general / Re: Newbie's firsttime with uTasker
« on: March 03, 2009, 09:48:13 PM »
So is it safe to say that ucInputMessage will contain hex when ran off the arm7 devel board instead of the simulator ?

12
µTasker general / Re: Newbie's firsttime with uTasker
« on: March 03, 2009, 08:25:07 PM »
Ok I'm running the simulator and when it gets to where it looks for '0x21' in ucInputMessage it actually has 33 which is the dec equiv to hex 0x21 ....
This causes problems as I need to see it in hex and NOT dec

13
µTasker general / Re: Newbie's firsttime with uTasker
« on: March 03, 2009, 04:13:28 AM »
Ok by running the simulator I'm finding the first value it gets is "33" which is the DEC equiv to "21" in hex.
Why would it be in DEC and not in HEX ? Is this something to do with fnRead ?

14
µTasker general / Re: Newbie's firsttime with uTasker
« on: March 03, 2009, 03:39:09 AM »
Now with that being finally solved and outta the way I seem to have some issue with my code.

In function fnReadIRD() where it says "if (ucInputMessage != 0x21) {" it never seems to equal 0x21

Now the device that sends the data to my ARM7 via uart1 has all it's packets start with 21 so I'm lost why it's not working with uTasker but the same code in the past has worked with other tasking projects ...

Any idea's ?

15
µTasker general / Re: Newbie's firsttime with uTasker
« on: March 03, 2009, 03:05:52 AM »
Let me explain what I did.

I extracted a fresh copy of utasker and utasker sp3

I then opened up taskconfig.h inside of the utaskerv1.3 folder and added in my iksclient task and then I also created a new file called iksclient.c and added in my own code.

I then debugged/compiled and it worked perfectly.

So after doing so I reloaded my old project located under folder iksclient and it started working as well.

So for some reason the changed I made to file TaskConfig.h in folder utaskerv1.3 reflected on what I was compiling in folder iksclient which should have been a seperate project folder all together with it's own taskconfig.h file but it would appear that when modifying taskconfig.h contained under iksclient folder it would do simply nothing.

any reason for this ? perchance it's a path or file setup incorrectly in utasker ?

Pages: [1] 2 3