
PRO
dbeard
USA
Asked
— Edited
Can anyone point me in the direction to find a way to tell how much time there is between two dates.
For example Date1 = 10/29/2016 10:30:54 PM and Date2 = 10/28/2016 7:00:01 AM
How many days, hours, minutes, and seconds before date 1.
@DJ I was using GetByteAt when I was using my Roomba ...example code snippet...
@PTP, @DJ... So my idea was a function call something like this... Not knowing C# limits my understanding of what can be done here so apologies...
What ever is in the buffer (if anything) would be read into $data... The complexity is removed... And It would be up to the user to pick out and/or convert the data he wants using maybe simple parser....
So what happens when you call "GetSerialData()" and you only get 1 byte, but your example code looks like it isexpecting 4 bytes.
This is the reason you have..
You can't trust that you ha
ve received all the data with a single command.
(see what i did there?)
@DJ... Ha, Ha... Touché..... Still function() commands to return data is a good idea...
No, it's not a good idea, as the example was presented
Additionally, using UARTRead() with binary/byte data is not recommended. UARTRead(), as the documentation dictates, is for ASCII String data.
Use UARTReadBinary(), which puts the data into an array.
To read all contents in one line, use this...
or for ASCII Read all, it's
Here's the info from the EZ-Script manual in ARC:
[feature] UARTRead( boardIndex, port, numBytes ) Receive ASCII bytes from the Peripheral UART Receive Buffer of the EZ-B v4. The UART receive buffers on the EZ-B v4 are 5,000 bytes. To know how many bytes are available, use the UARTAvailable() function. The Board Index is the EZ-B index starting at 0. The port can be 0, 1 or 2. Look near at the UART Port section lower in this document for the EZ-B Pin’s associated with each UART Port. Example: UARTRead(0, 0, 10) Example: UARTRead(0, 0, UARTAvailable(0, 1))
UARTReadBinary( boardIndex, port, numBytes, variable ) Receive binary bytes from the Peripheral UART Receive Buffer of the EZ-B v4 into the variable as an array. The UART receive buffers on the EZ-B v4 are 5,000 bytes. To know how many bytes are available, use the UARTAvailable() function. The Board Index is the EZ-B index starting at 0. The port can be 0, 1 or 2. Look near at the UART Port section lower in this document for the EZ-B Pin’s associated with each UART Port. Example: UARTReadBinary(0, 0, 10, $variable) Example: UARTReadBinary(0, 0, UARTAvailable(0, 1), $variable)
UARTReadAvailable( boardIndex, port ) Receive all available ASCII bytes from the Peripheral UART Receive Buffer of the EZ-B v4. The UART receive buffers on the EZ-B v4 are 5,000 bytes. The Board Index is the EZ-B index starting at 0. The port can be 0, 1 or 2. Look near at the UART Port section lower in this document for the EZ-B Pin’s associated with each UART Port. Example: UARTReadAvailable(0, 0) Example: UARTReadAvailable(0, 0) [/feature]
@DJ.... Got you. I do understand how it works, I just have to experiment further with UART... Learning to better parse the incoming information for the relevant data that I need is the next step....
Thanks
Did you also notice that the command you were asking for exists? I pasted it in the above message from the script manual. It's uartreadavailable(). It's just that I wouldn't recommend using it for your application.
Actually, I wouldn't use it for any application other than debugging. Because you do need to know how much data is in the buffer. And you should only read as much data as your expected packet size is and leave the other packets in the buffer to process on the next loop.