vbo
Get Status
Get the current logging flag.
vbo.get_status()
Returns the current flag value.
Pause
Pause the logging to the vbo file.
vbo.pause(state)
Input Parameters:
state[bool] = Whether to pause or unpause which is True or False respectively.
Pending samples
Get the amount of samples you have pending to be written use this function:
vbo.pending_samples()
It returns the amount of samples waiting to be written. This normally runs between 1 and 10 samples, occasionally this is longer if garbage collection has been triggered.
The max depth of this currently is 128 samples before the buffer circles back round to the beginning and data gets over-written.
Set App Information
Set the app info.
vbo.set_appinfo(buf)
Input Parameters:
buf[Buffer] = The application information string
We typically do the app name and the version like this:
vbo.set_appinfo('APP {}.{}.{}.{}'.format(1,0,0,0))
Note:
Only pass it characters contained within CP1252 as otherwise this could cause errors.
Set Created Format
Change how the date is formatted in the vbo file.
vbo.set_created_fmt(fmt)
Input Parameters:
fmt[int] = The format for the date: valid inputs are 0(DDMMYY) and 1(MMDDYY).
Set Resume Mode
Change between adding or not adding 0.5 seconds worth of data before moving, after resuming a log.
vbo.set_resume_mode(mode)
Input Parameters:
mode[int] = The logging resume mode: valid input are 0 = add 0.5s worth of data before moving began and 1 = start logging only when moving.
Start
Creates a new .vbo file and then starts the automatic logging.
vbo.start()
It also returns the file name of the file it has started creating if it is successful in doing so.
It will fail to open the file if there is currently logging active or if there is no SD Card present.
Stop
Stops the automatic logging and when it is next started it will be in a new file.
vbo.stop()
uPy Channels
upy_channel
Creates a uPy object.
a_channel = vbo.upy_channel(channel_Name, units, reference_Name)
Input Parameters:
channel_Name[string] = The name of the channel to be written to the vbo file header.
units[string] = The units of the channel for example ‘m/s’ for speed
reference_Name[string] = The name you will use in the code to reference the channel. This will also be the column name of your channel in the vbo file. WARNING: THIS CANNOT HAVE WHITE SPACE. Can be the same as the channel_Name.
Note
You cannot create a channel if there is logging currently active. This will throw an exception.
There is also no way to change any of the object data that you gave it after initialising the object other than to delete it.
Remove Channel Objects
Remove a channel object use:
a_channel.remove()
Note
You cannot delete a channel if there is logging currently active. This will throw an exception.
Set Channel Data
Set the value to be written to the vbo file.
a_channel.set_value(index, data)
Input Parameters:
index[int] = The sample_id of the current sample that you are logging.
data[int/float] = Any floating point number. The data value has to be a float or an int (as this can be converted to a float) as all vbo data is stored as floats.
Get Channel Data
Gets the channel data. Reference the channel you want the data from.
a_channel[index]
Input Parameters:
index[int] = The index of the channel data you want. The index ranges from 0-127 inclusive.
Trying do a slice of index or an index out of this range as this will throw an exception.
Clear the buffer
Clear the buffer of the data it is storing.
a_channel.clear_buffer()
This will set all the values in the buffer to 0.
Write to vbo
Write to the vbo file use the following function:
vbo.write_upy_channels(index)
Input Parameters:
index[int] = This is the index of the data to write from the buffer, it is associated with the sample_id.
This will set a flag to say that the sample is completed and that the line can be written. If it is given a sample_id ahead of where it previously was it will write all previous samples that hadn’t yet been logged.
This function can be called even if you haven’t set new data. In this case it will write the same data as it did for the previous sample (0 if it has never had data in).
Warning
If any upy_channel objects have been created, then the VBO task will not write any lines until write_upy_channels() has been called
This will raise an exception if there is no logging currently taking place.
Legacy functions: deprecated
Set Coldstart
vbo.set_coldstart()
Further Examples
G-Meter App - This app shows how to log from GPS data and CAN data at the same time and displays them each on separate pages.