termux / termux-api-package

Termux package containing scripts to call functionality in Termux:API.
MIT License
1.04k stars 321 forks source link

termux-sensor -s "TMD4906 RGB IR Sensor" on dreamlte: corrupted values (float instead of integer) #124

Closed jer194 closed 3 years ago

jer194 commented 3 years ago

Problem description @dreamlte:~/ termux-sensor -s "TMD4906 RGB IR Sensor"

In bright sunshine, the first (sommetimes the fifth) value seems to be misinterpreted as a floating point number.

Example sequence (compressed format):

1614328328 2021-02-26T09:32:08 { "ired": { "values": [ 16267, 423, 560, 610, 1551, 17, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] } }
1614329228 2021-02-26T09:47:08 { "ired": { "values": [ 20404, 252, 334, 361, 1864, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] } }
1614330128 2021-02-26T10:02:08 { "ired": { "values": [ 27463, 322, 417, 448, 2271, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] } }
1614331029 2021-02-26T10:17:09 { "ired": { "values": [ 1.8446744073709552E19, 183, 237, 258, 2513, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] } }
1614331929 2021-02-26T10:32:09 { "ired": { "values": [ 1.8446744073709552E19, 205, 271, 291, 2737, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] } }

Steps to reproduce Put an S8 / dreamlte into bright sunshine, and execute the command.

Expected behavior The first value probably should be interpreted as unsigned integer value, and maybe I4 instead of I2.

Additional information

@dreamlte:~/ termux-info

  Packages CPU architecture:
  aarch64
  Subscribed repositories:
  # sources.list
  deb https://termux.org/packages/ stable main
  # game-repo (sources.list.d/game.list)
  deb https://grimler.se/game-packages-24 games stable
  # science-repo (sources.list.d/science.list)
  deb https://grimler.se/science-packages-24 science stable
  Updatable packages:
  All packages up to date
  Android version:
  9
  Kernel build information:
  Linux dreamlte 4.4.111 #1 SMP PREEMPT Thu Feb 11 22:46:43 CET 2021 aarch64 Android
  Device manufacturer:
  samsung
  Device model:
  SM-G950F

logcat only shows this:

  02-26 11:17:52.128  5754  5754 I termux-api: Delay set to: 1000
  02-26 11:17:52.128  5754  5754 I termux-api: SensorOutput limit set to: 2147483647
jer194 commented 3 years ago

It doesn't look like a termux problem:

s8: dumpsys sensorservice

...
TMD4906 RGB IR Sensor: last 10 events
         1 (ts=427657.534586773, wall=11:08:28.930) 18446744073709551616.00, 1035.00, 1427.00, 1358.00, 14101.00, 17.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,      
...
Grimler91 commented 3 years ago

@jer194 are you on stock android or is this with a custom rom?

jer194 commented 3 years ago

That's LOS Pie, built by myself, using these additional packages:

 lineage-16.0 github.com/exynos8895 android_vendor_samsung_dreamlte vendor/samsung/dreamlte 
 lineage-16.0 github.com/exynos8895 android_vendor_samsung_universal8895-common vendor/samsung/universal8895-common 
 lineage-16.0 github.com/exynos8895 android_device_samsung_dreamlte device/samsung/dreamlte 
 lineage-16.0 github.com/exynos8895 android_device_samsung_universal8895-common device/samsung/universal8895-common 
 lineage-16.0 github.com/exynos8895 android_kernel_samsung_universal8895 kernel/samsung/universal8895 
 lineage-16.0 github.com/LineageOS  android_hardware_samsung             hardware/samsung
 lineage-16.0 github.com/LineageOS  android_packages_resources_devicesettings packages/resources/devicesettings
Grimler91 commented 3 years ago

LOS 17.1 from the same repos here, so probably/maybe specific to these sources

jer194 commented 3 years ago

So you observe the same issue on LOS17.1? If so, it should be something in the sensor driver code in the kernel I guess.

My S8 ROM is here btw: https://sourceforge.net/projects/jer194/files/Android/LOS16.0/

Grimler91 commented 3 years ago

So you observe the same issue on LOS17.1?

Yes.

jer194 commented 3 years ago

I'm trying to get sensor data directly from the kernel, without using all the layers in between. For battery it is pretty easy, everything is listed here (S8): /sys/devices/platform/battery/power_supply/battery/uevent

For other sensors, it is not that easy, the closest I could find is dumpsys. But probably some sensors need to be switched on, in order to deliver data.

termux seems to use some java API for this purpose.

Grimler91 commented 3 years ago

Everything available through termux-api comes from the android API, so only the info available from (for example) the battery manager is available: https://developer.android.com/reference/android/os/BatteryManager