Y
Y
Yu Yu2015-04-02 22:31:40
Java
Yu Yu, 2015-04-02 22:31:40

How to organize simultaneous access to a resource (I2C sensor) in JavaME?

There is a method of polling the sensor on the I2C bus (simplified)

private float readCurrentTemperatureValue() {
           I2CDevice lm75ad = DeviceManager.open(I2CDevice.class, config);
            lm75ad.begin();
            lm75ad.read(TEMPERATURE_REGISTER, REGISTER_ADDRESS_SIZE, rxBuf);
            lm75ad.end();
lm75ad.close();


Everything is good here.
But if the I2C bus is suddenly busy polling the RTC, for example, jdk.dio.UnavailableDeviceException should pop up, if I'm not mistaken.

I read that there is a method that waits until the resource is free tryLock(time); where to put it? instead of open?
How do you understand that the i2c bus is busy at the moment?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Martyanov, 2015-04-02
@vilgeforce

There is a suspicion that monitoring the bus will make it possible to understand whether it is busy at the moment or not. It seems like there are START and STOP states...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question