genesys: Return errors as exceptions from *asic_test()

merge-requests/104/head
Povilas Kanapickas 2019-07-20 11:02:04 +03:00
rodzic a0aa335d90
commit d8d1638fde
2 zmienionych plików z 12 dodań i 25 usunięć

Wyświetl plik

@ -1025,8 +1025,7 @@ gl646_setup_sensor (Genesys_Device * dev, const Genesys_Sensor& sensor, Genesys_
/** Test if the ASIC works /** Test if the ASIC works
*/ */
static SANE_Status static void gl646_asic_test(Genesys_Device* dev)
gl646_asic_test (Genesys_Device * dev)
{ {
DBG_HELPER(dbg); DBG_HELPER(dbg);
uint8_t val; uint8_t val;
@ -1042,16 +1041,14 @@ gl646_asic_test (Genesys_Device * dev)
if (val != 0xde) /* value of register 0x38 */ if (val != 0xde) /* value of register 0x38 */
{ {
DBG(DBG_error, "%s: register contains invalid value\n", __func__); throw SaneException("register contains invalid value");
return SANE_STATUS_IO_ERROR;
} }
sanei_genesys_read_register(dev, 0x4f, &val); sanei_genesys_read_register(dev, 0x4f, &val);
if (val != 0xad) /* value of register 0x39 */ if (val != 0xad) /* value of register 0x39 */
{ {
DBG(DBG_error, "%s: register contains invalid value\n", __func__); throw SaneException("register contains invalid value");
return SANE_STATUS_IO_ERROR;
} }
/* ram test: */ /* ram test: */
@ -1082,12 +1079,9 @@ gl646_asic_test (Genesys_Device * dev)
{ {
if (verify_data[i + 2] != data[i]) if (verify_data[i + 2] != data[i])
{ {
DBG(DBG_error, "%s: data verification error\n", __func__); throw SaneException("data verification error");
return SANE_STATUS_IO_ERROR;
} }
} }
return SANE_STATUS_GOOD;
} }
/** /**
@ -3506,7 +3500,7 @@ gl646_init (Genesys_Device * dev)
/* Test ASIC and RAM */ /* Test ASIC and RAM */
if (!(dev->model->flags & GENESYS_FLAG_LAZY_INIT)) if (!(dev->model->flags & GENESYS_FLAG_LAZY_INIT))
{ {
RIE (gl646_asic_test (dev)); gl646_asic_test(dev);
} }
/* send gamma tables if needed */ /* send gamma tables if needed */

Wyświetl plik

@ -290,9 +290,8 @@ static void sanei_gl841_setup_sensor(Genesys_Device * dev, const Genesys_Sensor&
/** Test if the ASIC works /** Test if the ASIC works
*/ */
/*TODO: make this functional*/ // TODO: make this functional
static SANE_Status static void sanei_gl841_asic_test(Genesys_Device* dev)
sanei_gl841_asic_test (Genesys_Device * dev)
{ {
DBG_HELPER(dbg); DBG_HELPER(dbg);
@ -300,27 +299,24 @@ sanei_gl841_asic_test (Genesys_Device * dev)
size_t size, verify_size; size_t size, verify_size;
unsigned int i; unsigned int i;
return SANE_STATUS_INVAL; throw SaneException("not implemented");
// set and read exposure time, compare if it's the same // set and read exposure time, compare if it's the same
sanei_genesys_write_register(dev, 0x38, 0xde); sanei_genesys_write_register(dev, 0x38, 0xde);
sanei_genesys_write_register(dev, 0x39, 0xad); sanei_genesys_write_register(dev, 0x39, 0xad);
sanei_genesys_read_register(dev, 0x38, &val); sanei_genesys_read_register(dev, 0x38, &val);
if (val != 0xde) /* value of register 0x38 */ if (val != 0xde) /* value of register 0x38 */
{ {
DBG(DBG_error, "%s: register contains invalid value\n", __func__); throw SaneException("register contains invalid value");
return SANE_STATUS_IO_ERROR;
} }
sanei_genesys_read_register(dev, 0x39, &val); sanei_genesys_read_register(dev, 0x39, &val);
if (val != 0xad) /* value of register 0x39 */ if (val != 0xad) /* value of register 0x39 */
{ {
DBG(DBG_error, "%s: register contains invalid value\n", __func__); throw SaneException("register contains invalid value");
return SANE_STATUS_IO_ERROR;
} }
/* ram test: */ /* ram test: */
@ -352,7 +348,6 @@ sanei_gl841_asic_test (Genesys_Device * dev)
{ {
if (verify_data[i] != data[i]) if (verify_data[i] != data[i])
{ {
DBG(DBG_error, "%s: data verification error\n", __func__);
DBG(DBG_info, "0x%.8x: got %.2x %.2x %.2x %.2x, expected %.2x %.2x %.2x %.2x\n", DBG(DBG_info, "0x%.8x: got %.2x %.2x %.2x %.2x, expected %.2x %.2x %.2x %.2x\n",
i, i,
verify_data[i], verify_data[i],
@ -363,11 +358,9 @@ sanei_gl841_asic_test (Genesys_Device * dev)
data[i+1], data[i+1],
data[i+2], data[i+2],
data[i+3]); data[i+3]);
return SANE_STATUS_IO_ERROR; throw SaneException("data verification error");
} }
} }
return SANE_STATUS_GOOD;
} }
/* /*
@ -4363,7 +4356,7 @@ gl841_init (Genesys_Device * dev)
/* Test ASIC and RAM */ /* Test ASIC and RAM */
if (!(dev->model->flags & GENESYS_FLAG_LAZY_INIT)) if (!(dev->model->flags & GENESYS_FLAG_LAZY_INIT))
{ {
RIE (sanei_gl841_asic_test (dev)); sanei_gl841_asic_test(dev);
} }
const auto& sensor = sanei_genesys_find_sensor_any(dev); const auto& sensor = sanei_genesys_find_sensor_any(dev);