Vai al contenuto

Weintek FREE PROTOCOL (Ethernet) how to

Home Forum Terminali operatore (Weintek) Weintek FREE PROTOCOL (Ethernet) how to

Stai visualizzando 2 post - dal 1 a 2 (di 2 totali)
  • Autore
    Post
  • #64696
    Chiara
    Partecipante

    On a the Weintek MT8071ip I can correctly read the data sent from an external TCP client using this macro combined with timing execution :

    macro_command main()
    char wResponse[20] = ""
    short receive_len = 0
    short wait_time = 1
    
    //FILL(wResponse[0],0,receive_len)
    TRACE("receive_len (A) = %d", receive_len) // Easy diagnoser: ritorna 0, ed è giusto
    INPORT(wResponse[0], "Free Protocol Server (Ethernet)", receive_len, wait_time)
    TRACE(" receive_len (B) = %d", receive_len) // ritorna sempre 0, anche se sono arrivati dei dati
    
    if receive_len >= 4 then
        SetData(wResponse[0], "Local HMI", LW, 0 , 20)
        TRACE(" receive_len3 = %d", receive_len) // qui non arriverà mai, se receive_lan non cambia valore
    end if
    end macro_command

    Every 5 second this run, but seems that always trigger the SetData(… even if there’s no data at all.
    If data are received these would disappear on next execution.
    Is there a way to enable a script debugger to check what happen inside the macro?

    #64710
    Sergio Bertana
    Amministratore del forum

    Non sò dove hai preso le informazioni sull’utilizzo della funzione INPORT, ma la tua macro và scritta in questo modo:

    macro_command main()
    char Response[20] = ""
    short RLength = 20 //Receive length
    short CRecvd = 0 //Received characters
    
    //FILL(Response[0],0,RLength)
    INPORT(Response[0], "Free Protocol Server (Ethernet)", RLength, CRecvd)
    
    if CRecvd >= 4 then
        TRACE(" CRecvd = %d", CRecvd)
        SetData(Response[0], "Local HMI", LW, 0 , 20)
    end if
    end macro_command

    In pratica definisci la quantità massima di caratteri da leggere in RLength, mentre in CRecvd viene ritornato il numero di caratteri letti.

Stai visualizzando 2 post - dal 1 a 2 (di 2 totali)
  • Devi essere connesso per rispondere a questo topic.