const mboard_eeprom_t& e300_eeprom_manager::read_mb_eeprom(void) { boost::mutex::scoped_lock(_mutex); std::vector<boost::uint8_t> bytes; bytes.resize(sizeof(mb_eeprom_map_t)); mb_eeprom_map_t *map_ptr = reinterpret_cast<mb_eeprom_map_t*>(&bytes[0]); memset(map_ptr, 0xff, sizeof(mb_eeprom_map_t)); // get the old contents for(size_t i = 0; i < sizeof(mb_eeprom_map_t); i++) bytes[i] = _i2c->get_i2c_reg8(MB_ADDR, i); mb_eeprom_map_t &map = *map_ptr; _mb_eeprom["product"] = boost::lexical_cast<std::string>( uhd::ntohx<boost::uint16_t>(map.hw_product)); _mb_eeprom["revision"] = boost::lexical_cast<std::string>( uhd::ntohx<boost::uint16_t>(map.hw_revision)); _mb_eeprom["serial"] = _bytes_to_string( map.serial, MB_SERIAL_LEN); byte_vector_t mac_addr(map.mac_addr, map.mac_addr + 6); _mb_eeprom["mac-addr"] = mac_addr_t::from_bytes(mac_addr).to_string(); _mb_eeprom["name"] = _bytes_to_string( map.user_name, MB_NAME_LEN); return _mb_eeprom; }
const dboard_eeprom_t& e300_eeprom_manager::read_db_eeprom(void) { boost::mutex::scoped_lock(_mutex); std::vector<boost::uint8_t> bytes; bytes.resize(sizeof(db_eeprom_map_t)); db_eeprom_map_t *map_ptr = reinterpret_cast<db_eeprom_map_t*>(&bytes[0]); memset(map_ptr, 0xff, sizeof(db_eeprom_map_t)); // get the old contents for(size_t i = 0; i < sizeof(db_eeprom_map_t); i++) bytes[i] = _i2c->get_i2c_reg16(DB_ADDR, i); db_eeprom_map_t &map = *map_ptr; _db_eeprom.id = uhd::usrp::dboard_id_t::from_uint16( uhd::ntohx<boost::uint16_t>(map.hw_product)); _db_eeprom.revision = boost::lexical_cast<std::string>( uhd::ntohx<boost::uint16_t>(map.hw_revision)); _db_eeprom.serial = _bytes_to_string( map.serial, DB_SERIAL_LEN); return _db_eeprom; }
const mboard_eeprom_t& n230_eeprom_manager::read_mb_eeprom() { boost::mutex::scoped_lock lock(_mutex); //Read EEPROM from device _transact(N230_FLASH_COMM_CMD_READ_NV_DATA); const n230_eeprom_map_t* map_ptr = reinterpret_cast<const n230_eeprom_map_t*>(_response.data); const n230_eeprom_map_t& map = *map_ptr; uint16_t ver_major = uhd::htonx<uint16_t>(map.data_version_major); uint16_t ver_minor = uhd::htonx<uint16_t>(map.data_version_minor); _mb_eeprom["product"] = std::to_string( uhd::htonx<uint16_t>(map.hw_product)); _mb_eeprom["revision"] = std::to_string( uhd::htonx<uint16_t>(map.hw_revision)); //The revision_compat field does not exist in version 1.0 //EEPROM version 1.0 will only exist on HW revision 1 so it is safe to set //revision_compat = revision if (ver_major == 1 and ver_minor == 0) { _mb_eeprom["revision_compat"] = _mb_eeprom["revision"]; } else { _mb_eeprom["revision_compat"] = std::to_string( uhd::htonx<uint16_t>(map.hw_revision_compat)); } _mb_eeprom["serial"] = _bytes_to_string( map.serial, N230_EEPROM_SERIAL_LEN); //Extract ethernet info _mb_eeprom["gateway"] = boost::asio::ip::address_v4( uhd::htonx<uint32_t>(map.gateway)).to_string(); for (size_t i = 0; i < N230_MAX_NUM_ETH_PORTS; i++) { const std::string n(1, i+'0'); _mb_eeprom["ip-addr"+n] = boost::asio::ip::address_v4( uhd::htonx<uint32_t>(map.eth_info[i].ip_addr)).to_string(); _mb_eeprom["subnet"+n] = boost::asio::ip::address_v4( uhd::htonx<uint32_t>(map.eth_info[i].subnet)).to_string(); byte_vector_t mac_addr(map.eth_info[i].mac_addr, map.eth_info[i].mac_addr + 6); _mb_eeprom["mac-addr"+n] = mac_addr_t::from_bytes(mac_addr).to_string(); } _mb_eeprom["name"] = _bytes_to_string( map.user_name, N230_EEPROM_NAME_LEN); return _mb_eeprom; }
static hlt_string _object_to_string(const hlt_type_info* type, void* obj, __hlt_pointer_stack* seen, hlt_exception** excpt, hlt_execution_context* ctx) { if ( type->gc ) { void *ptr = *(void **)obj; if ( __hlt_pointer_stack_lookup(seen, ptr) ) return hlt_string_from_asciiz("[... recursion ...]", excpt, ctx); __hlt_pointer_stack_push_back(seen, ptr); } hlt_string s; binpac_type_id id = binpac_type_get_id(type, excpt, ctx); switch ( id ) { case BINPAC_TYPE_ADDRESS: s = _addr_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_BOOL: s = _bool_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_BITFIELD: s = _bitfield_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_BYTES: s = _bytes_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_DOUBLE: s = _double_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_EMBEDDED_OBJECT: s = _embedded_to_string(type, obj, seen, excpt, ctx); break ; case BINPAC_TYPE_ENUM: s = _enum_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_INTEGER_SIGNED: s = _sint_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_INTEGER_UNSIGNED: s = _uint_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_INTERVAL: s = _interval_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_ITERATOR_BYTES: s = _iter_bytes_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_LIST: s = _list_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_MAP: s = _map_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_OPTIONAL: s = _optional_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_PORT: s = _port_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_REGEXP: s = _regexp_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_SET: s = _set_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_SINK: s = _sink_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_STRING: s = _string_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_TIME: s = _time_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_TUPLE: s = _tuple_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_UNIT: s = _unit_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_VECTOR: s = _vector_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_VOID: s = _void_to_string(type, obj, seen, excpt, ctx); break; case BINPAC_TYPE_NONE: fprintf(stderr, "internal error: BinPAC type not set in HILTI rtti object when rendering (HILTI type: %d/%s)\n", type->type, type->tag); abort(); default: fprintf(stderr, "internal error: BinPAC type %" PRIu64 " not supported fo rendering (HILTI type: %d/%s)\n", id, type->type, type->tag); abort(); } if ( type->gc ) __hlt_pointer_stack_pop_back(seen); return s; }