Start a new topic
Solved

V0.37 addt command

I have trubble with the waveform cmd addt.

My code is. (plain c on psoc)

  

 //test for addt
uint8 i;
sprintf(tmpString,   
      "addt 3,1,%i",
      100);  
nextSendCommand((const char8*)tmpString);    //addt 3,1,100  wait for 100 points (ID 3, CH 1, 100 points)
        
uint8 nxReturnLen = uartWaitForStr(10); //wait 10 ms for 0xFE
if ((nxReturnLen == 1) &&
    (uartString[0] == NEX_RET_DATA_TRANSPARENT_TRANSMIT_READY))
{
   for (i=0;i<100;i++)    //100 * add 3,3,i
   {
       sprintf(tmpString,       
          "add 3,1,%i",
            i);  
        nextSendCommand((const char8*)tmpString);   
     }
 } 

   


In debugger occurs the same problem. 

Is this a bug, or have i misunderstood the addt command? 


From the description of add and addt in the Nextion Instruction Set,


If your command is sent as 'addt 3,1,100' and received by Nextion, Nextion preps space up to 1024 bits (at 8-bit values that's up to 128 values)  -- you requested 800 bits, 100 values

So at this point Nextion clears space for your 100 byte values and after a portion of time near ~5ms later, Nextion sends out 0xFE to let you know you can now begin to send your data through.


Once your host MCU receives the FE indicator, you should be sending 100 byte values in Hexadecimal.

Nothing but a 200 char length string of your hex data for 100 points.


Your command of 'add 3,1,1'+FF+FF+FF is interpreted with zeros replacing failed hex conversions 

0xAD (ad), 0x00 (d ), 0x00 (3,), 0x00 (1,), 0x1F(1F),0xFF(FF),0xFF(FF),0xFA (Fa), 0xDD (dd) ...


Something along those lines as your text command to use add instead of just the hex value is being interpreted as incoming data until 200 bytes (1 byte per hex character) has been received.


You might have received a sloped line had you not issued prior addt. command.


Armed with this info, try again, and let me know.



1 person likes this

@Patrick

Oh, my mistake.

Thx for your explanation!

Now, i understood addt and it works as it should.

This code works well. 

//test for addt
uint8 i;
sprintf(tmpString,   
	"addt 3,1,%i",
	100);  
nextSendCommand((const char8*)tmpString);    //addt 3,1,100  wait for 100 points (ID 3, CH 1, 100 points)

uint8 nxReturnLen = uartWaitForStr(10); //wait 10 ms for 0xFE
if ((nxReturnLen == 1) &&
	(uartString[0] == NEX_RET_DATA_TRANSPARENT_TRANSMIT_READY))
{
	for (i=0;i<100;i++)    //100 chars
	{
		UART_UartPutChar(i);  //puts 1 char 
	}
}

 

And much more efficiently as well.


Originally sending 100 commands at average 13 chars (add 3,1,45+FFFFFF) processed individually ~1291 bytes, verses you code now using 116 bytes of bandwidth and only two transactions being processed.  Time, bandwidth and clock cycles that could be better used elsewhere.


1 person likes this

Yes, and if use .val in add command, i would be happy ;-)


Hi Reiner. Can you show all your code? Because I am not underst.

Hi Yayang,


The Code fragment is only a little test for me to understand who the addt command works. Patrick explained it well.

The code is written for a PSoC4 without any libs for NEXTION. 


//nextSendCommand - is only a wrapper around the plain UART_PRINT_STR() 

 

//for arduino without NEXTION lib, maybe like this  (i'm not sure)
void nextSendCommand((const char8*)sendString) 
{
   Serial.print(sendString);
   Serial.write(0xFF); 
   Serial.write(0xFF); 
   Serial.write(0xFF); 
}

UART_UartPutChar() - is a native UART API Function in PSoC

For Arduino is Serial.write()


uartWaitForStr(uint32 ms)

Is a litte function, (for PSoC)

This function reads bytes from UART until the end sign (0xFF 0xFF 0xFF) comes or even the waitTime (ms) is over.

Is the waitTime not over, the function returns the lenght of the received string without 0x00 0x00 0x00

In this case, the receives bytes in stands in uartString[]


My original HMI (DHTTEST.HMI) can you found here http://support.iteadstudio.com/support/discussions/topics/11000005749

The waveform component is located on page dht3.


And if the page dht3 activ, you can use the addt - command

  

//test addt command
sprintf(tmpString,                              
	"addt 3,1,%i",   //block send to waveformID 3, ch 1 for the
	100);            //block lenght = 100 bytes
	
nextSendCommand((const char8*)tmpString);    //send addt command

/*
   wait 10 ms for NEXTION response 1 byte and the byte is 0xFE (see addt instruction)
*/
if ((uartWaitForStr(10) == 1) &&  
	(uartString[0] == NEX_RET_DATA_TRANSPARENT_TRANSMIT_READY)) 
{
	//put a block from 100byte to NEXTION
	uint8 i;
	for (i=0;i<100;i++) 
	{
		UART_UartPutChar(i);  //put 1 byte
	}
}

  

Hi Reiner


The add 1,0,va0.val is on the Feature Request list.

I will deem that we have solved this question and mark it as solved