User Tools

Site Tools


doc:crazyflie:crtp:mem

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:crazyflie:crtp:mem [2014-11-10 10:19]
macke
doc:crazyflie:crtp:mem [2020-05-12 14:22] (current)
kimberly
Line 1: Line 1:
 +<WRAP center round important 60%>
 +This page has deprecated and moved to the new documentation framework of the main Bitcraze website. Please go to [[https://www.bitcraze.io/documentation/system/]]
 +</WRAP>
 +
 +
 +
 +====== Memory access ======
 +Memory access is not used for the [[projects:crazyflie:index|Crazyflie Nano Quadcopter]], it's currently only implemented in the Crazyflie 2.0. Using the memory access gives the possibility to:
 +  * Get information about which memories are available
 +  * Read/write/erase memories
 +
 +Currently the following memories are supported:
 +  * Crazyflie 2.0 onboard EEPROM
 +  * Crazyflie 2.0 expansion board 1-wire memories
 +
 +There's more information available for how the EEPROM is structured and how the 1-wire memories work and are structured.
 +
 +====== Logical flow ======
 +Getting information and reading/writing the memories is optional for the clients, but the -Crazyflie Python Client- always downloads information about the memories on connect.
 +
 +<ditaa>
 +    /------------------------\      /-------------------\     /----------------\   No    /------\
 +--> | Get number of memories |----->| Fetch memory info |---->| More memories? |-------->| Done |
 +    \------------------------/      \-------------------/     \----------------/         \------/
 +                                              ^                        |
 +                                              |                        |
 +                                              \------------------------/
 +                                                          Yes
 +</ditaa>
 +====== Communication protocol ======
 +The memory port uses 3 different channels:
 +^ **Port**  ^ **Channel** ^ **Function**      ^
 +|            0        | Get information about amount and types of memory as well as erasing |
 +|            1        | Read memories |
 +|            2        | Write memories |
 +
 +===== Channel 0: Info/settings =====
 +This channel is used to get the number of memories present, information about the memories and the possibility to mass erase memories. The first byte of every packet is a command byte:
 +
 +^ Command byte ^    Command      ^ Operation ^
 +|        1     | GET_NBR_OF_MEMS | Get the number of memories |
 +|        2     | GET_MEM_INFO    | Get information about a memory |
 +|        3     | SET_MEM_ERASE   | Mass erase a memory |
 +
 +==== GET_NBR_OF_MEMS ====
 +This command is used to get the number of memories present.
 +
 +The request from host to Crazyflie:
 +^ Byte ^     Field            ^  Value ^  Length  ^   Comment         ^
 +|  0    GET_NUMBER_OF_MEMS  |  0x01  |        | The command byte |
 +
 +Reply from Crazyflie to host:
 +^ Byte ^     Field            ^  Value ^  Length  ^  Comment  ^
 +|  0    GET_NUMBER_OF_MEMS  |  0x01  |        | The command byte |
 +|  1    Number of memories  |        |        | The number of memories preset (all types) |
 +
 +Example where there are 3 memories present on the Crazyflie:
 +<code>
 +Host-to-Crazyflie: <port/chan> 0x01
 +Crazyflie-to-Host: <port/chan> 0x01 0x03
 +</code>
 +
 +==== GET_MEM_INFO ====
 +This command is used to get information about a memory give it's id. The id of memories is sequential and is from 0 to one less than the returned number of memories from GET_NUMBER_OF_MEMS.
 +
 +The request from host to Crazyflie:
 +^ Byte ^     Field      ^  Value ^  Length  ^  Comment  ^
 +|  0    GET_MEM_INFO  |  0x02  |        | The command byte |
 +|  1     MEM_ID              |        | A memory id that is 0 <= id < NBR_OF_MEMS |
 +
 +Reply from Crazyflie to host if the id is valid:
 +^ Byte ^     Field      ^  Value ^  Length  ^  Comment  ^
 +|  0    GET_MEM_INFO  |  0x02  |        | The command byte |
 +|  1     MEM_ID              |        | The memory id |
 +|  2     MEM_TYPE            |        | The memory type (see below) |
 +|  3     MEM_SIZE            |        | The size in bytes of the memory |
 +|  7     MEM_ADDR            |        | The address of the memory (only valid for 1-wire memories) |
 +
 +Where the MEM_TYPE field is:
 +^ MEM_TYPE ^  Memory type  ^  Comment  ^
 +|  0         I2C                   |
 +|  1          1-wire               |
 +
 +Reply from Crazyflie to host if the id is not valid:
 +^ Byte ^     Field      ^  Value ^  Length  ^  Comment  ^
 +|  0    GET_MEM_INFO  |  0x02  |        | The command byte |
 +|  1     MEM_ID              |        | The memory id |
 +
 +Example of requesting the information for a 1-wire memory with MEM_ID=1, MEM_SIZE=112bytes, MEM_ADDR=0x1234567890ABCDEF
 +<code>
 +Host-to-Crazyflie: <port/chan> 0x02 0x01
 +Crazyflie-to-Host: <port/chan> 0x02 0x01 0x01 0x70 0x00 0x00 0x00 0xEF 0xCD 0xAB 0x90 0x78 0x56 0x34 0x12
 +</code>
 +
 +Example of requesting the information for a memory index that is not valid
 +<code>
 +Host-to-Crazyflie: <port/chan> 0x01 0x10
 +Crazyflie-to-Host: <port/chan> 0x01 0x10
 +</code>
 +
 +==== SET_MEM_ERASE ====
 +This command is used to mass erase a memory with a given id. The id of memories is sequential and is from 0 to one less than the returned number of memories from GET_NUMBER_OF_MEMS.
 +
 +The request from host to Crazyflie:
 +^ Byte ^     Field      ^  Value ^  Length  ^  Comment  ^
 +|  0    SET_MEM_ERASE  |  0x03  |        | The command byte |
 +|  1     MEM_ID        |        |        | A memory id that is 0 <= id < NBR_OF_MEMS |
 +
 +Reply from Crazyflie to host:
 +^ Byte ^     Field      ^  Value ^  Length  ^  Comment  ^
 +|  0    SET_MEM_ERASE |  0x03  |        | The command byte |
 +|  1     MEM_ID              |        | The memory id |
 +|  2     STATUS              |        | The status of the command (see below) |
 +
 +
 +Example of requesting a mass erase for a memory with MEM_ID=2
 +<code>
 +Host-to-Crazyflie: <port/chan> 
 +Crazyflie-to-Host: <port/chan> 
 +</code>
 +
 +Example of
 +<code>
 +Host-to-Crazyflie: <port/chan> 
 +Crazyflie-to-Host: <port/chan> 
 +</code>
 +
 +===== Channel 1: Memory read =====
 +This channel is only used to read memories and therefore the messages do not contain any command byte.
 +
 +The request from host to Crazyflie:
 +^ Byte ^     Field      ^  Value ^  Length  ^  Comment  ^
 +|  0     MEM_ID              |        | A memory id that is 0 <= id < NBR_OF_MEMS |
 +|  1     MEM_ADDR            |        | The address where the first byte should be read |
 +|  5     LEN          |        |        | The number of bytes to be read |
 +
 +Reply from Crazyflie to host if memory id is valid and the address and length to be read is valid:
 +^ Byte ^     Field      ^  Value ^  Length  ^  Comment  ^
 +|  0     MEM_ID              |  1       | A memory id that is 0 <= id < NBR_OF_MEMS |
 +|  1     MEM_ADDR            |  4       | The address where the first byte should be read |
 +|  5     STATUS              |  1       | The status of the request (see below) |
 +|  6     DATA                |  1..24?  | The data that was read (only if MEM_ID/MEM_ADDR/LEN is valid) |
 +
 +Where the STATUS field is:
 +^  STATUS  ^  Comment  ^
 +|  0          ...    |
 +|  1          ....   |
 +
 +Example of reading LEN=0x0F bytes from MEM_ID=0x01 MEM_ADDR=0x0A
 +<code>
 +Host-to-Crazyflie: <port/chan> 0x01 0x0A 0x00 0x00 0x00 0x0F
 +Crazyflie-to-Host: <port/chan> 0x01 0x0A 0x00 0x00 0x00 0x00 0x01 0x09 0x62 0x63 0x4C 0x65 0x64 0x52 0x69 0x6E 0x67 0x02 0x01 0x62 0x55 
 +</code>
 +
 +===== Channel 2: Memory write =====
 +This channel is only used to write memories and therefore the messages do not contain any command byte.
 +
 +The request from host to Crazyflie:
 +^ Byte ^     Field      ^  Value ^  Length  ^  Comment  ^
 +|  0     MEM_ID              |        | A memory id that is 0 <= id < NBR_OF_MEMS |
 +|  1     MEM_ADDR            |        | The address where the first byte should be read |
 +|  5     DATA                |   1..24? | The data to be written |
 +
 +Reply from Crazyflie to host if memory id is valid and the address and length to be written is valid:
 +^ Byte ^     Field      ^  Value ^  Length  ^  Comment  ^
 +|  0     MEM_ID              |  1       | A memory id that is 0 <= id < NBR_OF_MEMS |
 +|  1     MEM_ADDR            |  4       | The address where the first byte should be read |
 +|  4     STATUS              |  1       | The status of the request (see below) |
 +
 +Where the STATUS field is:
 +^  STATUS  ^  Comment  ^
 +|  0          ...    |
 +|  1          ....   |
 +
 +Example
 +<code>
 +
 +</code>