Tutorial: Memory Map

Implementing the Memory Map

The memory map xml file allows you to specify how address blocks in memory are defined. When the xml file is loaded, the data defined in the memory map will be injected as properties of the defined JavaScript object.

Simple Data Types

Several simple data types are available for use. These include:

  • bool - a boolean value representing true or false
  • bits - a user-specified number of bits
  • u8 - unsigned 8 bit integer
  • u16 - unsigned 16 bit integer
  • u32 - unsigned 32 bit integer
  • s8 - signed 8 bit integer
  • s16 - signed 16 bit integer
  • s32 - signed 32 bit integer
  • cstring - character string terminated by a null (ASCII 00) character
  • string - character string where the first 4 bytes define the string length

Composite Data Types

Aside from the simple types, you can use the tag to define composite user defined data types. Within these user defined data types you can specify a combination of simple data types. For example:

<!-- A user defined data type representing a person -->
    <udt name="person" size="40">
        <cstring name="firstname" index="0" size="16" />
        <cstring name="lastname" index="2" size="16" />
        <u16 index="4" name="height" />
        <u16 index="6" name="weight" />
        <u16 index="8" name="age" />

Memory Map

Once you have defined the composite data types, you need to define them in the memory map section as follows:

<!-- An FLNet memory map definition example -->
<input1 type="person" />
<input2 type="person" />

A note on Endianness

Endianness is the byte ordering used to represent data. The device uses a Little Endian data representation. This means that the least significant byte (LSB) value, is at the lowest address. The other bytes follow in increasing order of significance. This could be relevant if the connecting system uses a Big-Endian representation. Failure to account for varying endianness could lead to communication problems for multi-byte data types such as u16, u32, s16, s32, cstring, and string as well as any custom types you define.