Byte Array

Glossary Item Box

Microsoft Robotics Developer Studio Send feedback on this topic

Byte Array

Byte Array

Byte Array - Icon

The Byte Array service provides a mechanism to create an array of bytes. Typically, this is used through the "Set Initial Configuration" mechanism. This can be useful for sending a raw data packets containing binary information.

The service provides the following requests. These are also provided as notifications.

Request Description
ByteArrayToList Converts an array of bytes to a byte list.
ByteListToArray Converts a list of bytes to a byte array.
GetArray Gets an array of bytes.
GetList Gets a list of bytes.

In most cases you will want to initialize the Byte Array when the program starts. To do this, select the Byte Array activity and in the Properties toolbox select the "Set initial configuration" option from the Configuration drop-down list. Click on the plus sign (+) beside the Count for the ByteList Data. For each element of the list, enter a value between 0 and 255, i.e. an unsigned byte value. The following screenshot shows an example with five elements. Notice that they are numbered from 0 to 4.

Configure Byte Array

Byte Array - Initialize an array

Elements of a Byte Array can be accessed in a Calculate block or as a Data Connection (if you specify "Edit values directly") by getting the array and using the syntax Data[index] where index is the number of the element in the array starting from zero. If you try to access an element beyond the length of the array, there will be an error at runtime (although VPL ignores it) and the returned value will be null.

To manipulate a Byte Array in VPL, i.e. add or remove elements, you can convert it to a List and use the List Functions service. When you have finished updating the list you can convert it back to a Byte Array.

 

 

© 2012 Microsoft Corporation. All Rights Reserved.