Difference between revisions of "Pf calb table py"

From DIDEAS Wiki
Jump to: navigation, search
m
m (access)
Line 85: Line 85:
  
 
=access=
 
=access=
Use "robo_config.py" to read / write these tables.
+
*Use "robo_config.py" to read / write these tables.
robo_config.py -p <serial port> -l  
+
*robo_config.py -p <serial port> -l  
will list all the tables in the robot
+
*will list all the tables in the robot

Revision as of 20:40, 7 December 2010

PF Users Navigation:

Edit


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

pyshared.c

...
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 {
  UINT32_T crc;          // this is the standard header, use CRC8 for now.
  UINT16_T version;      
  UINT16_T length;        
  UINT32_T magic;        // "hash" for this typedef from the file pygen_shared_object_hash_codes.h
  //////////////////
  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