This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UART PROBLEM ARM lpc1769

I want change easyweb to communicate with the camera and send hex data (camera) up through enthernet computer.
I used the arm to connect to the camera via uart, but my problem is getting data from the camera with a piece of lost data when I put the counter(nn) above 315bytes.
my camera send data HEX about 12kb.
What is my problem?
way to solve?
my code received data from camera: while(1){ pdata[nn] = UARTGetChar(LPC_UART0);

if (nn==280)(break;}

nn++; }

Parents
  • So we still don't have any idea what you may do wrong because you still don't show us what you are doing?

    I am currently implementing/testing a time/frequency capture module for a product. Can you tell me what I might have done wrong? No - I'm not letting you see the code but knowing that the code should either measure frequency or period length should be enough, don't you think? Because that is basically how much info you are giving us.

    Are we expected to hack your computer to see what you may possibly do wrong?

Reply
  • So we still don't have any idea what you may do wrong because you still don't show us what you are doing?

    I am currently implementing/testing a time/frequency capture module for a product. Can you tell me what I might have done wrong? No - I'm not letting you see the code but knowing that the code should either measure frequency or period length should be enough, don't you think? Because that is basically how much info you are giving us.

    Are we expected to hack your computer to see what you may possibly do wrong?

Children
  • my code a lot, so I can not give up all
    I will take a camera interface
    int main (void)
    {

    TCPLowLevelInit ();

    HTTPStatus = 0; / / clear HTTP-server's flag register

    TCPLocalPort = TCP_PORT_HTTP; / / set port we want to listen to

    while (1) / / repeat forever {

    if (! (SocketStatus & SOCK_ACTIVE)) TCPPassiveOpen (); DoNetworkStuff ();

    receiver (); / / this is the function control characters from a computer via enthernet

    }
    } void receiver (void)
    { uint8_t kytu1;
    unsigned char h; if (SocketStatus & SOCK_CONNECTED) / / check if somebody has connected to our TCP { if (SocketStatus & SOCK_DATA_AVAILABLE) / / check if remote TCP sent data { unsigned int HTTPBytestorec = TCPRxDataCount; rec = TCP_RX_BUF; TCPReleaseRxBuffer ();

    pData = (unsigned char *) malloc (100);

    switch (* (rec)) { default:{

    if (! (HTTPStatus & HTTP_SEND_PAGE)) //allows flow only 1 times {

    capture ();//this function camera settings } else {

    dt ();//Here is a function to receive the data from the camera and send it to your computer via LAN }

    break; }
    void dt(void)
    { uint8_t ii=0; uint16_t m,gan;

    data[12]=pdata[nn-2];// SETTING ADDRESS data[13]=pdata[nn-1];//SETTING ADDRESS free(pdata);

    pdata=(unsigned char *)malloc(1000); n=0; while(n==0){ n=UART_Send(LPC_UART0,data,16,BLOCKING);}//SEND ADDRESS TO CAMERA

    while (UART_CheckBusy(LPC_UART0)==SET );

    nn=0; while(1){

    pdata[nn] = UARTGetChar(LPC_UART0);// RECEIVED DATA FROM CAMERA, MY PROBLEM HERE

    if (nn==280) { break;

    }

    nn++;

    }

    ........TEST DATA RECEIVED FULL DATA (ABOUT 12K)

    nn=256;//NUMBER CHAR SEND ON COMPUTER

    transmit();//Here is a function to send the data from the camera to the computer via LAN

    return;
    } void transmit(void)
    {

    if (SocketStatus & SOCK_CONNECTED) {

    if(SocketStatus & SOCK_TX_BUF_RELEASED) {

    memcpy(TCP_TX_BUF,pdata,nn); TCPTxDataCount=nn; TCPTransmitTxBuffer();

    free(pdata);

    }

    }

    }

    when I set variables(nn) above 315bytes it lost the data so each time I have to get under 315byte
    so time-consuming 4-5s to get a frame and sent to the computer.

    I need to get all the data from the camera and send it to your computer in one single program flow.

  • my code

    int main (void)
    {
    
    TCPLowLevelInit ();
    
    HTTPStatus = 0; / / clear HTTP-server's flag register
    
    TCPLocalPort = TCP_PORT_HTTP; / / set port we want to listen to
    
    while (1) / / repeat forever
    {
    
    if (! (SocketStatus & SOCK_ACTIVE)) TCPPassiveOpen ();
     DoNetworkStuff ();
    
    receiver (); / / this is the function control characters from a computer via enthernet
    
    }
    }
    void receiver (void)
    {
    uint8_t kytu1;
    unsigned char h;
    if (SocketStatus & SOCK_CONNECTED) / / check if somebody has connected to our TCP
    {
       if (SocketStatus & SOCK_DATA_AVAILABLE) / / check if remote TCP sent data
           {
              unsigned int HTTPBytestorec = TCPRxDataCount;
    
              rec = TCP_RX_BUF; TCPReleaseRxBuffer ();
    
              pData = (unsigned char *) malloc (100);
    
    switch (* (rec))
    {
    default:{
    
    if (! (HTTPStatus & HTTP_SEND_PAGE)) //allows flow only 1 times
    {
    
    capture ();//this function camera settings }
    else {
    
    dt ();//Here is a function to receive the data from the camera and send it to your computer via LAN }
    
    break;
    }
    void dt(void)
    { uint8_t ii=0;
     uint16_t m,gan;
    
    data[12]=pdata[nn-2];        // SETTING ADDRESS
    data[13]=pdata[nn-1];/       /SETTING ADDRESS
    
         free(pdata);
    
    pdata=(unsigned char *)malloc(1000);
    n=0;
     while(n==0)
    {
          n=UART_Send(LPC_UART0,data,16,BLOCKING);}//SEND ADDRESS TO CAMERA
    
    while (UART_CheckBusy(LPC_UART0)==SET );
    
    nn=0;
    while(1){
    
    pdata[nn] = UARTGetChar(LPC_UART0);// RECEIVED DATA FROM CAMERA, MY PROBLEM HERE
    
    if (nn==280) { break;
    
    }
    
    nn++;
    
    }
    
    ........TEST DATA RECEIVED FULL DATA (ABOUT 12K)
    
    nn=256;//NUMBER CHAR SEND ON COMPUTER
    
    transmit();//Here is a function to send the data from the camera to the computer via LAN
    
    return;
    }
    
    void transmit(void)
    {
    
    if (SocketStatus & SOCK_CONNECTED) {
    
    if(SocketStatus & SOCK_TX_BUF_RELEASED) {
    
    memcpy(TCP_TX_BUF,pdata,nn); TCPTxDataCount=nn; TCPTransmitTxBuffer();
    
    free(pdata);
    
    }
    
    }
    
    }
    

  • Do you really lay-out your code like that?

    Do you really find that clear and easy to read?

  • Are you making fun of us?

    Did you think your code looked good? No indentation?

    Do you _really_ write code looking like:

    if (nn==280) { break;
    
    }
    


    Not even:

    if (nn==280) {
        break;
    }
    

    Or did you just copied the already broken code (resulting from you not caring about my first post suggesting how to post source code) and reposted it again - without noticing that it still looked like a mess?

    One issue with your code - having a single loop to receive all data over UART takes time. During that time, you don't service the TCP/IP stack.

    You really should consider having interrupt-based UART communication that can happen concurrently with other things and then make the TCP communication when you have performed a correct transfer from the camera.

    Another thing - why do you love global variables so much. The code is full of assigns to variables that are neither local or parameters to the function. Variable scope was invented because it greatly increases the readability and maintainability. Maintainability - the ability to see what code does and modify code without breaking it.

    Your code don't do any error handling.

        ...
        // *** How do you know this function, that you say will send, really will send???
        transmit();//Here is a function to send the data from the camera to the computer via LAN
    
        return;
    }
    
    void transmit(void) {
        if (SocketStatus & SOCK_CONNECTED) {
            if(SocketStatus & SOCK_TX_BUF_RELEASED) {
                memcpy(TCP_TX_BUF,pdata,nn);
                TCPTxDataCount=nn;
                TCPTransmitTxBuffer();
                free(pdata);
            }
        }
    }
    


    Notice that transmit() have two if statements. Only if you pass them will you get into the code that seems to transmit - how is your UART code (that allocates a buffer for the incomming data) take this into account?

    Start looking at the TCP/IP examples.
    Then start trying to "unmess" your code a bit.
    Keep track of the current state.
    Make sure that functions returns error results if they may fail.
    Make sure that you always check error results.
    Try some debugging, to compare where you assumptions deviates from what the program actually do.

    And when you post code next time - make sure it does look readable.

  • what is wrong in the code

    global_temp1 = multiptr2_init1; route1(); DVAorIP2(); decode2bytes(); changesoutput1(); global_temp1 = configpm[glbtmpvar]; PORTD = ' '; if (multiptr2_init1<17) { PORTD = 'b'; if (multiptr2_init1 & 0x01) { PORTD = 'a'; } } ASCII_TO_LCD(); PORTD = 0xC9; dis(); J_num = 16; second_name(); PORTD = 0xDC; dis(); decode2bytes(); PORTD = 0xE1; dis(); changesoutput2(); global_temp2 = configpm[glbtmpvar]; if (multiptr2_init1 & 0x01) { global_temp1 = global_temp2 >> 4; } else { global_temp1 = global_temp2 & 0x0F; } decode2bytes(); } else if (screen_num == 26)

  • Dear all (helpers),

    Please stop paying attention to this thread. You are genuinely wasting your time...

  • Thanks for the reply
    ..updates questions