int16_t lome6_get_temperature(ow_rom_code_t * rom) { int16_t retval = 0x7FFF; /* error */ ow_sensor_t * sensor = ow_find_sensor(rom); if (sensor != NULL) { ow_temp_t temp = sensor->temp; retval = (temp.twodigits ? temp.val / 10 : temp.val); } return retval; }
int16_t parse_cmd_onewire_list(char *cmd, char *output, uint16_t len) { uint8_t firstonbus = 0; int16_t ret; if (ow_global.lock == 0) { firstonbus = 1; #if ONEWIRE_BUSCOUNT > 1 ow_global.bus = 0; #endif OW_DEBUG_LIST("called onewire list for the first time\n"); #ifdef ONEWIRE_DS2502_SUPPORT /* parse optional parameters */ while (*cmd == ' ') cmd++; switch (*cmd) { case 't': ow_global.list_type = OW_LIST_TYPE_TEMP_SENSOR; break; case 'e': ow_global.list_type = OW_LIST_TYPE_EEPROM; break; case '\0': ow_global.list_type = OW_LIST_TYPE_ALL; break; default: return ECMD_ERR_PARSE_ERROR; } #endif } else { OW_DEBUG_LIST("called onewire list again\n"); firstonbus = 0; } #if defined ONEWIRE_DS2502_SUPPORT || ONEWIRE_BUSCOUNT > 1 list_next:; #endif #if ONEWIRE_BUSCOUNT > 1 ret = ow_search_rom((uint8_t) (1 << (ow_global.bus + ONEWIRE_STARTPIN)), firstonbus); #else ret = ow_search_rom(ONEWIRE_BUSMASK, firstonbus); #endif /* make sure only one conversion happens at a time */ ow_global.lock = 1; if (ret == 1) { #ifdef ONEWIRE_DS2502_SUPPORT if (ow_global.list_type == OW_LIST_TYPE_ALL || (ow_global.list_type == OW_LIST_TYPE_TEMP_SENSOR && ow_temp_sensor(&ow_global.current_rom)) || (ow_global.list_type == OW_LIST_TYPE_EEPROM && ow_eeprom(&ow_global.current_rom))) { /* only print device rom address if it matches the selected list type */ #endif OW_DEBUG_LIST("discovered device " #if ONEWIRE_BUSCOUNT > 1 "%02x %02x %02x %02x %02x %02x %02x %02x on bus %d\n", #else "%02x %02x %02x %02x %02x %02x %02x %02x\n", #endif ow_global.current_rom.bytewise[0], ow_global.current_rom.bytewise[1], ow_global.current_rom.bytewise[2], ow_global.current_rom.bytewise[3], ow_global.current_rom.bytewise[4], ow_global.current_rom.bytewise[5], ow_global.current_rom.bytewise[6], ow_global.current_rom.bytewise[7] #if ONEWIRE_BUSCOUNT > 1 , ow_global.bus); #else ); #endif #ifdef ONEWIRE_NAMING_SUPPORT char *name = ""; ow_sensor_t *sensor = ow_find_sensor(&ow_global.current_rom); if (sensor != NULL && sensor->named) { name = sensor->name; } #endif ret = snprintf_P(output, len, PSTR("%02x%02x%02x%02x%02x%02x%02x%02x" #ifdef ONEWIRE_NAMING_SUPPORT "\t%s" #endif ), ow_global.current_rom.bytewise[0], ow_global.current_rom.bytewise[1], ow_global.current_rom.bytewise[2], ow_global.current_rom.bytewise[3], ow_global.current_rom.bytewise[4], ow_global.current_rom.bytewise[5], ow_global.current_rom.bytewise[6], ow_global.current_rom.bytewise[7] #ifdef ONEWIRE_NAMING_SUPPORT , name #endif ); OW_DEBUG_LIST("generated %d bytes\n", ret); /* set return value that the parser has to be called again */ if (ret > 0) ret = ECMD_AGAIN(ret); OW_DEBUG_LIST("returning %d\n", ret); return ECMD_FINAL(ret); #ifdef ONEWIRE_DS2502_SUPPORT }