Difference between revisions of "Pf calb table py"
From DIDEAS Wiki
m (→access) |
m (→global.h) |
||
Line 32: | Line 32: | ||
<pre> | <pre> | ||
typedef struct { | typedef struct { | ||
− | UINT32_T | + | // preamble that should appear at the start of all shared objects - use the same field names |
− | UINT16_T | + | UINT32_T pytable_crc; // this is the standard header, use CRC8 for now. |
− | UINT16_T | + | UINT16_T pytable_version; |
− | UINT32_T | + | UINT16_T pytable_length; |
+ | UINT32_T pytable_magic; // "hash" for this typedef from the file pygen_shared_object_hash_codes.h | ||
+ | |||
////////////////// | ////////////////// | ||
+ | // use table data to follow. only use 'primitive' C types | ||
UINT32_T count; | UINT32_T count; | ||
} PERSISTENT_DATA_T; | } PERSISTENT_DATA_T; | ||
Line 43: | Line 46: | ||
extern PERSISTENT_DATA_T persistent_data_c2; | extern PERSISTENT_DATA_T persistent_data_c2; | ||
</pre> | </pre> | ||
+ | |||
==global.c== | ==global.c== | ||
<pre> | <pre> |
Revision as of 20:45, 7 December 2010
PF Users Navigation:
- PCB; Lifefix_users; Pf_users; benchtest_users; CalibFix Users; Hardware; Assembly ; iochan ;
- PCA : PCB ; AKENC SC/MC 218 ; FET 217 ; IMU219 ; Swifi ; Rev200_mods ; PCA Inventory
- Special Commands to the Ankle (PFCMD) : State Controller Commands; Motor Controller Commands; Python Examples; IMU Commands ;PFCMD_PY; Pf_calb_table_py; Virtual spring test; PF EEPROM
- DOC: Pf_users; Powerfoot Keyboard User Interface; Steps for Manual Tuning; "Dashboard" Program For Assisting with Tuning
- NEW (CEB) WIKI
- Torque Feedback Controller Guide
Contents
files to modify
- add eeprom address to eeprom_memmap.h
- could be else where, but helps us to keep track of what is being used where
- add macros to pyshared.c that list the global ram address, and or EEPROM address and virtual variable name
- to global.c, declare the global
- to global.h, define the global typedef
- latter two (global) files are optional, but help keep everything in one place
example
eeprom_memmap.h
#define PERSISTENT_DATA_C1_EEPROM_BASE_ADDRESS 0x1500 #define PERSISTENT_DATA_C2_EEPROM_BASE_ADDRESS 0x1580
... const SHARED_OBJECT_T SHARED_OBJECT[] = { ... SHARED_RAM_OBJ_M(PERSISTENT_DATA_T, persistent_data_c1), // use commas at EOL SHARED_RAM_OBJ_M(PERSISTENT_DATA_T, persistent_data_c2), SHARED_EE_OBJ_M (PERSISTENT_DATA_T, EE_persistent_data_c1, PERSISTENT_DATA_C1_EEPROM_BASE_ADDRESS), SHARED_EE_OBJ_M (PERSISTENT_DATA_T, EE_persistent_data_c2, PERSISTENT_DATA_C2_EEPROM_BASE_ADDRESS), ... } ;
global.h
typedef struct { // preamble that should appear at the start of all shared objects - use the same field names UINT32_T pytable_crc; // this is the standard header, use CRC8 for now. UINT16_T pytable_version; UINT16_T pytable_length; UINT32_T pytable_magic; // "hash" for this typedef from the file pygen_shared_object_hash_codes.h ////////////////// // use table data to follow. only use 'primitive' C types UINT32_T count; } PERSISTENT_DATA_T; extern PERSISTENT_DATA_T persistent_data_c1; extern PERSISTENT_DATA_T persistent_data_c2;
global.c
PERSISTENT_DATA_T persistent_data_c1; PERSISTENT_DATA_T persistent_data_c2; void init_global(void) { ... ZERO_OBJ(persistent_data_c1); ZERO_OBJ(persistent_data_c2); ... }
how to load / save
A general purpose solution does not yet exist. However common_files/eeprom_table.c and the following are an example:
ERRCODE_T persistent_load() { ERRCODE_T ecode; MEMORY_ADDRESS_T mem; PERSISTENT_DATA_T local_stack_obj; UINT16_T table_size = sizeof( PERSISTENT_DATA_T); mem.type = MEMORY_TYPE_TO_USE_FOR_TABLE_STORAGE; mem.address = PERSISTENT_DATA_C1_EEPROM_BASE_ADDRESS; // copy EEPROM table into local storage until it is validated ecode = eeprom_table_read( (TABLE_HEADER_T *)&local_stack_obj, table_size, &mem, PERSISTENT_DATA_T_HASH); // PERSISTENT_DATA_T_HASH comes from pygen_shared_object_hash_codes.h and is 32 bits of the MD5 HASH of the typedef source code. if (ecode) return ecode; // invalid table // if there were no errors and thus the table is valid, then copy into the walking_param state structure ecode = memcpy((UINT8_T *)&persistent_data_c1, (UINT8_T *)&local_stack_obj, table_size); return ecode; }
access
- Use "robo_config.py" to read / write these tables.
- robo_config.py -p <serial port> -l
- will list all the tables in the robot