This commit is contained in:
pelikhan 2021-11-17 23:31:36 -08:00
Родитель e3ec628e42
Коммит efa07d8861
61 изменённых файлов: 173 добавлений и 66 удалений

Просмотреть файл

@ -4,6 +4,6 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
Resources:
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns

Просмотреть файл

@ -4,7 +4,7 @@
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below.
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](<https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)>), please report it to us as described below.
## Reporting Security Issues
@ -12,19 +12,19 @@ If you believe you have found a security vulnerability in any Microsoft-owned re
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue
- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
- Full paths of source file(s) related to the manifestation of the issue
- The location of the affected source code (tag/branch/commit or direct URL)
- Any special configuration required to reproduce the issue
- Step-by-step instructions to reproduce the issue
- Proof-of-concept or exploit code (if possible)
- Impact of the issue, including how an attacker might exploit the issue
This information will help us triage your report more quickly.
@ -38,4 +38,4 @@ We prefer all communications to be in English.
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
<!-- END MICROSOFT SECURITY.MD BLOCK -->
<!-- END MICROSOFT SECURITY.MD BLOCK -->

Просмотреть файл

@ -1,13 +1,13 @@
# Support
## How to file issues and get help
## How to file issues and get help
This project uses [GitHub Issues](https://github.com/microsoft/jacdac/discussions) to track bugs and feature requests. Please search the existing
issues before filing new issues to avoid duplicates. For new issues, file your bug or
This project uses [GitHub Issues](https://github.com/microsoft/jacdac/discussions) to track bugs and feature requests. Please search the existing
issues before filing new issues to avoid duplicates. For new issues, file your bug or
feature request as a new Issue.
For help and questions about using this project, please use https://github.com/microsoft/jacdac/discussions.
## Microsoft Support Policy
## Microsoft Support Policy
Support for this **PROJECT or PRODUCT** is limited to the resources listed above.

Просмотреть файл

@ -1 +1 @@
from .client import *
from .client import *

Просмотреть файл

@ -3,14 +3,15 @@ from .constants import *
from typing import Union
from jacdac.events import HandlerFn
class AccelerometerClient(Client):
"""
A 3-axis accelerometer.
"""
def __init__(self, bus: Bus, role: str) -> None:
super().__init__(bus, JD_SERVICE_CLASS_ACCELEROMETER, JD_ACCELEROMETER_PACK_FORMATS, role)
super().__init__(bus, JD_SERVICE_CLASS_ACCELEROMETER,
JD_ACCELEROMETER_PACK_FORMATS, role)
@property
def x(self) -> Union[float, None]:
@ -58,7 +59,6 @@ class AccelerometerClient(Client):
reg = self.register(JD_ACCELEROMETER_REG_MAX_FORCE)
reg.set_value(0, value)
def on_tilt_up(self, handler: HandlerFn) -> None:
"""
Emitted when accelerometer is tilted in the given direction.
@ -130,5 +130,3 @@ class AccelerometerClient(Client):
Emitted when force in any direction exceeds given threshold.
"""
# TODO

Просмотреть файл

@ -5,6 +5,8 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_ARCADE_GAMEPAD = const(0x1deaa06e)
class ArcadeGamepadButton(Enum):
LEFT = const(0x1)
UP = const(0x2)
@ -17,6 +19,7 @@ class ArcadeGamepadButton(Enum):
RESET = const(0x9)
EXIT = const(0xa)
JD_ARCADE_GAMEPAD_REG_BUTTONS = const(JD_REG_READING)
JD_ARCADE_GAMEPAD_REG_AVAILABLE_BUTTONS = const(0x180)
JD_ARCADE_GAMEPAD_EV_DOWN = const(JD_EV_ACTIVE)

Просмотреть файл

@ -5,12 +5,15 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_AZURE_IOT_HUB_HEALTH = const(0x1462eefc)
class AzureIotHubHealthConnectionStatus(Enum):
CONNECTED = const(0x1)
DISCONNECTED = const(0x2)
CONNECTING = const(0x3)
DISCONNECTING = const(0x4)
JD_AZURE_IOT_HUB_HEALTH_REG_HUB_NAME = const(0x180)
JD_AZURE_IOT_HUB_HEALTH_REG_HUB_DEVICE_ID = const(0x181)
JD_AZURE_IOT_HUB_HEALTH_REG_CONNECTION_STATUS = const(0x182)

Просмотреть файл

@ -5,6 +5,8 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_BARCODE_READER = const(0x1c739e6c)
class BarcodeReaderFormat(Enum):
AZTEC = const(0x1)
CODE128 = const(0x2)
@ -20,6 +22,7 @@ class BarcodeReaderFormat(Enum):
UPC_A = const(0xd)
UPC_E = const(0xe)
JD_BARCODE_READER_REG_ENABLED = const(JD_REG_INTENSITY)
JD_BARCODE_READER_REG_FORMATS = const(0x180)
JD_BARCODE_READER_EV_DETECT = const(JD_EV_ACTIVE)

Просмотреть файл

@ -1 +1 @@
from .client import *
from .client import *

Просмотреть файл

@ -10,7 +10,6 @@ class BarometerClient(Client):
def __init__(self, bus: Bus, role: str) -> None:
super().__init__(bus, JD_SERVICE_CLASS_BAROMETER, JD_BAROMETER_PACK_FORMATS, role)
@property
def pressure(self) -> Union[float, None]:
@ -27,5 +26,3 @@ class BarometerClient(Client):
"""
reg = self.register(JD_BAROMETER_REG_PRESSURE_ERROR)
return reg.value(0)

Просмотреть файл

@ -1 +1 @@
from .client import *
from .client import *

Просмотреть файл

@ -1,2 +1,2 @@
class ButtonServer:
pass
pass

Просмотреть файл

@ -5,15 +5,19 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_CHARACTER_SCREEN = const(0x1f37c56a)
class CharacterScreenVariant(Enum):
LCD = const(0x1)
OLED = const(0x2)
BRAILLE = const(0x3)
class CharacterScreenTextDirection(Enum):
LEFT_TO_RIGHT = const(0x1)
RIGHT_TO_LEFT = const(0x2)
JD_CHARACTER_SCREEN_REG_MESSAGE = const(JD_REG_VALUE)
JD_CHARACTER_SCREEN_REG_BRIGHTNESS = const(JD_REG_INTENSITY)
JD_CHARACTER_SCREEN_REG_VARIANT = const(JD_REG_VARIANT)

Просмотреть файл

@ -1,5 +1,6 @@
def const(v: int): return v
# A shim for the micropython const keyword
# A shim for the micropython const keyword
JD_SERIAL_HEADER_SIZE = const(16)
JD_SERIAL_MAX_PAYLOAD_SIZE = const(236)
@ -29,10 +30,12 @@ CMD_EVENT_CODE_MASK = const(0xff)
CMD_EVENT_COUNTER_MASK = const(0x7f)
CMD_EVENT_COUNTER_POS = const(8)
def JD_GET(code: int):
assert 0 <= code and code <= 0xfff
return CMD_GET_REG | code
def JD_SET(code: int):
assert 0 <= code and code <= 0xfff
return CMD_SET_REG | code

Просмотреть файл

@ -5,11 +5,14 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_DIMMER = const(0x1fb02645)
class DimmerVariant(Enum):
LIGHT = const(0x1)
FAN = const(0x2)
PUMP = const(0x3)
JD_DIMMER_REG_INTENSITY = const(JD_REG_INTENSITY)
JD_DIMMER_REG_VARIANT = const(JD_REG_VARIANT)
JD_DIMMER_PACK_FORMATS = {

Просмотреть файл

@ -5,12 +5,15 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_DISTANCE = const(0x141a6b8a)
class DistanceVariant(Enum):
ULTRASONIC = const(0x1)
INFRARED = const(0x2)
LI_DAR = const(0x3)
LASER = const(0x4)
JD_DISTANCE_REG_DISTANCE = const(JD_REG_READING)
JD_DISTANCE_REG_MIN_RANGE = const(JD_REG_MIN_READING)
JD_DISTANCE_REG_MAX_RANGE = const(JD_REG_MAX_READING)

Просмотреть файл

@ -5,10 +5,13 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_DOT_MATRIX = const(0x110d154b)
class DotMatrixVariant(Enum):
LED = const(0x1)
BRAILLE = const(0x2)
JD_DOT_MATRIX_REG_DOTS = const(JD_REG_VALUE)
JD_DOT_MATRIX_REG_BRIGHTNESS = const(JD_REG_INTENSITY)
JD_DOT_MATRIX_REG_ROWS = const(0x181)

Просмотреть файл

@ -5,10 +5,13 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_E_CO2 = const(0x169c9dc6)
class ECO2Variant(Enum):
VOC = const(0x1)
NDIR = const(0x2)
JD_E_CO2_REG_E_CO2 = const(JD_REG_READING)
JD_E_CO2_REG_E_CO2_ERROR = const(JD_REG_READING_ERROR)
JD_E_CO2_REG_MIN_E_CO2 = const(JD_REG_MIN_READING)

Просмотреть файл

@ -5,10 +5,13 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_FLEX = const(0x1f47c6c6)
class FlexVariant(Enum):
LINEAR22INCH = const(0x1)
LINEAR45INCH = const(0x2)
JD_FLEX_REG_BENDING = const(JD_REG_READING)
JD_FLEX_REG_VARIANT = const(JD_REG_VARIANT)
JD_FLEX_PACK_FORMATS = {

Просмотреть файл

@ -5,6 +5,8 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_HEART_RATE = const(0x166c6dc4)
class HeartRateVariant(Enum):
FINGER = const(0x1)
CHEST = const(0x2)
@ -12,6 +14,7 @@ class HeartRateVariant(Enum):
PUMP = const(0x4)
WEB_CAM = const(0x5)
JD_HEART_RATE_REG_HEART_RATE = const(JD_REG_READING)
JD_HEART_RATE_REG_HEART_RATE_ERROR = const(JD_REG_READING_ERROR)
JD_HEART_RATE_REG_VARIANT = const(JD_REG_VARIANT)

Просмотреть файл

@ -4,6 +4,8 @@ Autogenerated constants for HID Keyboard service
from enum import Enum
from jacdac.constants import *
JD_SERVICE_CLASS_HID_KEYBOARD = const(0x18b05b6a)
class HidKeyboardModifiers(Enum):
NONE = const(0x0)
LEFT_CONTROL = const(0x1)
@ -15,11 +17,13 @@ class HidKeyboardModifiers(Enum):
RIGHT_ALT = const(0x40)
RIGHT_GUI = const(0x80)
class HidKeyboardAction(Enum):
PRESS = const(0x0)
UP = const(0x1)
DOWN = const(0x2)
JD_HID_KEYBOARD_CMD_KEY = const(0x80)
JD_HID_KEYBOARD_CMD_CLEAR = const(0x81)
JD_HID_KEYBOARD_PACK_FORMATS = {

Просмотреть файл

@ -4,17 +4,21 @@ Autogenerated constants for HID Mouse service
from enum import Enum
from jacdac.constants import *
JD_SERVICE_CLASS_HID_MOUSE = const(0x1885dc1c)
class HidMouseButton(Enum):
LEFT = const(0x1)
RIGHT = const(0x2)
MIDDLE = const(0x4)
class HidMouseButtonEvent(Enum):
UP = const(0x1)
DOWN = const(0x2)
CLICK = const(0x3)
DOUBLE_CLICK = const(0x4)
JD_HID_MOUSE_CMD_SET_BUTTON = const(0x80)
JD_HID_MOUSE_CMD_MOVE = const(0x81)
JD_HID_MOUSE_CMD_WHEEL = const(0x82)

Просмотреть файл

@ -5,6 +5,8 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_JOYSTICK = const(0x108f7456)
class JoystickButtons(Enum):
LEFT = const(0x1)
UP = const(0x2)
@ -19,12 +21,14 @@ class JoystickButtons(Enum):
X = const(0x400)
Y = const(0x800)
class JoystickVariant(Enum):
THUMB = const(0x1)
ARCADE_BALL = const(0x2)
ARCADE_STICK = const(0x3)
GAMEPAD = const(0x4)
JD_JOYSTICK_REG_DIRECTION = const(JD_REG_READING)
JD_JOYSTICK_REG_VARIANT = const(JD_REG_VARIANT)
JD_JOYSTICK_REG_BUTTONS_AVAILABLE = const(0x180)

Просмотреть файл

@ -5,12 +5,15 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_LED = const(0x1e3048f8)
class LedVariant(Enum):
THROUGH_HOLE = const(0x1)
SMD = const(0x2)
POWER = const(0x3)
BEAD = const(0x4)
JD_LED_CMD_ANIMATE = const(0x80)
JD_LED_REG_COLOR = const(0x180)
JD_LED_REG_MAX_POWER = const(JD_REG_MAX_POWER)

Просмотреть файл

@ -5,11 +5,14 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_LED_PIXEL = const(0x126f00e0)
class LedPixelLightType(Enum):
WS2812B_GRB = const(0x0)
APA102 = const(0x10)
SK9822 = const(0x11)
class LedPixelVariant(Enum):
STRIP = const(0x1)
RING = const(0x2)
@ -17,6 +20,7 @@ class LedPixelVariant(Enum):
JEWEL = const(0x4)
MATRIX = const(0x5)
JD_LED_PIXEL_REG_BRIGHTNESS = const(JD_REG_INTENSITY)
JD_LED_PIXEL_REG_ACTUAL_BRIGHTNESS = const(0x180)
JD_LED_PIXEL_REG_LIGHT_TYPE = const(0x80)

Просмотреть файл

@ -5,11 +5,14 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_LIGHT_LEVEL = const(0x17dc9a1c)
class LightLevelVariant(Enum):
PHOTO_RESISTOR = const(0x1)
LEDMATRIX = const(0x2)
AMBIENT = const(0x3)
JD_LIGHT_LEVEL_REG_LIGHT_LEVEL = const(JD_REG_READING)
JD_LIGHT_LEVEL_REG_VARIANT = const(JD_REG_VARIANT)
JD_LIGHT_LEVEL_PACK_FORMATS = {

Просмотреть файл

@ -5,12 +5,15 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_MATRIX_KEYPAD = const(0x13062dc8)
class MatrixKeypadVariant(Enum):
MEMBRANE = const(0x1)
KEYBOARD = const(0x2)
ELASTOMER = const(0x3)
ELASTOMER_LEDPIXEL = const(0x4)
JD_MATRIX_KEYPAD_REG_PRESSED = const(JD_REG_READING)
JD_MATRIX_KEYPAD_REG_ROWS = const(0x180)
JD_MATRIX_KEYPAD_REG_COLUMNS = const(0x181)

Просмотреть файл

@ -5,11 +5,14 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_MODEL_RUNNER = const(0x140f9a78)
class ModelRunnerModelFormat(Enum):
TFLITE = const(0x334c4654)
ML4F = const(0x30470f62)
EDGE_IMPULSE_COMPILED = const(0x30564945)
JD_MODEL_RUNNER_CMD_SET_MODEL = const(0x80)
JD_MODEL_RUNNER_CMD_PREDICT = const(0x81)
JD_MODEL_RUNNER_REG_AUTO_INVOKE_EVERY = const(0x80)

Просмотреть файл

@ -5,9 +5,12 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_MOTION = const(0x1179a749)
class MotionVariant(Enum):
PIR = const(0x1)
JD_MOTION_REG_MOVING = const(JD_REG_READING)
JD_MOTION_REG_MAX_DISTANCE = const(0x180)
JD_MOTION_REG_ANGLE = const(0x181)

Просмотреть файл

@ -1 +1 @@
from .client import *
from .client import *

Просмотреть файл

@ -9,8 +9,8 @@ class PotentiometerClient(Client):
"""
def __init__(self, bus: Bus, role: str) -> None:
super().__init__(bus, JD_SERVICE_CLASS_POTENTIOMETER, JD_POTENTIOMETER_PACK_FORMATS, role)
super().__init__(bus, JD_SERVICE_CLASS_POTENTIOMETER,
JD_POTENTIOMETER_PACK_FORMATS, role)
@property
def position(self) -> Union[float, None]:
@ -27,5 +27,3 @@ class PotentiometerClient(Client):
"""
reg = self.register(JD_POTENTIOMETER_REG_VARIANT)
return reg.value(0)

Просмотреть файл

@ -5,10 +5,13 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_POTENTIOMETER = const(0x1f274746)
class PotentiometerVariant(Enum):
SLIDER = const(0x1)
ROTARY = const(0x2)
JD_POTENTIOMETER_REG_POSITION = const(JD_REG_READING)
JD_POTENTIOMETER_REG_VARIANT = const(JD_REG_VARIANT)
JD_POTENTIOMETER_PACK_FORMATS = {

Просмотреть файл

@ -5,12 +5,15 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_POWER = const(0x1fa4c95a)
class PowerPowerStatus(Enum):
DISALLOWED = const(0x0)
POWERING = const(0x1)
OVERLOAD = const(0x2)
OVERPROVISION = const(0x3)
JD_POWER_REG_ALLOWED = const(JD_REG_INTENSITY)
JD_POWER_REG_MAX_POWER = const(JD_REG_MAX_POWER)
JD_POWER_REG_POWER_STATUS = const(0x181)

Просмотреть файл

@ -5,11 +5,14 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_REAL_TIME_CLOCK = const(0x1a8b1a28)
class RealTimeClockVariant(Enum):
COMPUTER = const(0x1)
CRYSTAL = const(0x2)
CUCKOO = const(0x3)
JD_REAL_TIME_CLOCK_REG_LOCAL_TIME = const(JD_REG_READING)
JD_REAL_TIME_CLOCK_REG_ERROR = const(0x180)
JD_REAL_TIME_CLOCK_REG_PRECISION = const(0x181)

Просмотреть файл

@ -5,10 +5,13 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_REFLECTED_LIGHT = const(0x126c4cb2)
class ReflectedLightVariant(Enum):
INFRARED_DIGITAL = const(0x1)
INFRARED_ANALOG = const(0x2)
JD_REFLECTED_LIGHT_REG_BRIGHTNESS = const(JD_REG_READING)
JD_REFLECTED_LIGHT_REG_VARIANT = const(JD_REG_VARIANT)
JD_REFLECTED_LIGHT_EV_DARK = const(JD_EV_INACTIVE)

Просмотреть файл

@ -1 +1 @@
from .client import *
from .client import *

Просмотреть файл

@ -3,6 +3,7 @@ from .constants import *
from typing import Union
from jacdac.events import HandlerFn
class RelayClient(Client):
"""
A switching relay.
@ -10,7 +11,6 @@ class RelayClient(Client):
def __init__(self, bus: Bus, role: str) -> None:
super().__init__(bus, JD_SERVICE_CLASS_RELAY, JD_RELAY_PACK_FORMATS, role)
@property
def closed(self) -> Union[bool, None]:
@ -25,7 +25,6 @@ class RelayClient(Client):
reg = self.register(JD_RELAY_REG_CLOSED)
reg.set_value(0, value)
@property
def variant(self) -> Union[RelayVariant, None]:
"""
@ -55,5 +54,3 @@ class RelayClient(Client):
Normally closed (NC) relays open the circuit when activated.
"""
# TODO

Просмотреть файл

@ -5,11 +5,14 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_RELAY = const(0x183fe656)
class RelayVariant(Enum):
ELECTROMECHANICAL = const(0x1)
SOLID_STATE = const(0x2)
REED = const(0x3)
JD_RELAY_REG_CLOSED = const(JD_REG_INTENSITY)
JD_RELAY_REG_VARIANT = const(JD_REG_VARIANT)
JD_RELAY_REG_MAX_SWITCHING_CURRENT = const(0x180)

Просмотреть файл

@ -5,11 +5,14 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_RNG = const(0x1789f0a2)
class RngVariant(Enum):
QUANTUM = const(0x1)
ADCNOISE = const(0x2)
WEB_CRYPTO = const(0x3)
JD_RNG_REG_RANDOM = const(0x180)
JD_RNG_REG_VARIANT = const(JD_REG_VARIANT)
JD_RNG_PACK_FORMATS = {

Просмотреть файл

@ -1 +1 @@
from .client import *
from .client import *

Просмотреть файл

@ -9,8 +9,8 @@ class RotaryEncoderClient(Client):
"""
def __init__(self, bus: Bus, role: str) -> None:
super().__init__(bus, JD_SERVICE_CLASS_ROTARY_ENCODER, JD_ROTARY_ENCODER_PACK_FORMATS, role)
super().__init__(bus, JD_SERVICE_CLASS_ROTARY_ENCODER,
JD_ROTARY_ENCODER_PACK_FORMATS, role)
@property
def position(self) -> Union[float, None]:
@ -28,5 +28,3 @@ class RotaryEncoderClient(Client):
"""
reg = self.register(JD_ROTARY_ENCODER_REG_CLICKS_PER_TURN)
return reg.value(0)

Просмотреть файл

@ -5,6 +5,8 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_SENSOR_AGGREGATOR = const(0x1d90e1c5)
class SensorAggregatorSampleType(Enum):
U8 = const(0x8)
I8 = const(0x88)
@ -13,6 +15,7 @@ class SensorAggregatorSampleType(Enum):
U32 = const(0x20)
I32 = const(0xa0)
JD_SENSOR_AGGREGATOR_REG_INPUTS = const(0x80)
JD_SENSOR_AGGREGATOR_REG_NUM_SAMPLES = const(0x180)
JD_SENSOR_AGGREGATOR_REG_SAMPLE_SIZE = const(0x181)

Просмотреть файл

@ -5,10 +5,13 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_SOIL_MOISTURE = const(0x1d4aa3b3)
class SoilMoistureVariant(Enum):
RESISTIVE = const(0x1)
CAPACITIVE = const(0x2)
JD_SOIL_MOISTURE_REG_MOISTURE = const(JD_REG_READING)
JD_SOIL_MOISTURE_REG_MOISTURE_ERROR = const(JD_REG_READING_ERROR)
JD_SOIL_MOISTURE_REG_VARIANT = const(JD_REG_VARIANT)

Просмотреть файл

@ -5,11 +5,14 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_SOLENOID = const(0x171723ca)
class SolenoidVariant(Enum):
PUSH_PULL = const(0x1)
VALVE = const(0x2)
LATCH = const(0x3)
JD_SOLENOID_REG_PULLED = const(JD_REG_INTENSITY)
JD_SOLENOID_REG_VARIANT = const(JD_REG_VARIANT)
JD_SOLENOID_PACK_FORMATS = {

Просмотреть файл

@ -5,6 +5,8 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_SWITCH = const(0x1ad29402)
class SwitchVariant(Enum):
SLIDE = const(0x1)
TILT = const(0x2)
@ -15,6 +17,7 @@ class SwitchVariant(Enum):
MAGNETIC = const(0x7)
FOOT_PEDAL = const(0x8)
JD_SWITCH_REG_ACTIVE = const(JD_REG_READING)
JD_SWITCH_REG_VARIANT = const(JD_REG_VARIANT)
JD_SWITCH_REG_AUTO_OFF_DELAY = const(0x180)

Просмотреть файл

@ -4,10 +4,13 @@ Autogenerated constants for TCP service
from enum import Enum
from jacdac.constants import *
JD_SERVICE_CLASS_TCP = const(0x1b43b70b)
class TcpTcpError(Enum):
INVALID_COMMAND = const(0x1)
INVALID_COMMAND_PAYLOAD = const(0x2)
JD_TCP_CMD_OPEN = const(0x80)
JD_TCP_PIPE_OPEN_SSL = const(0x1)
JD_TCP_PIPE_ERROR = const(0x0)

Просмотреть файл

@ -1 +1 @@
from .client import *
from .client import *

Просмотреть файл

@ -9,8 +9,8 @@ class ThermocoupleClient(Client):
"""
def __init__(self, bus: Bus, role: str) -> None:
super().__init__(bus, JD_SERVICE_CLASS_THERMOCOUPLE, JD_THERMOCOUPLE_PACK_FORMATS, role)
super().__init__(bus, JD_SERVICE_CLASS_THERMOCOUPLE,
JD_THERMOCOUPLE_PACK_FORMATS, role)
@property
def temperature(self) -> Union[float, None]:
@ -51,5 +51,3 @@ class ThermocoupleClient(Client):
"""
reg = self.register(JD_THERMOCOUPLE_REG_VARIANT)
return reg.value(0)

Просмотреть файл

@ -5,6 +5,8 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_THERMOCOUPLE = const(0x143ac061)
class ThermocoupleVariant(Enum):
TYPE_K = const(0x1)
TYPE_J = const(0x2)
@ -15,6 +17,7 @@ class ThermocoupleVariant(Enum):
TYPE_R = const(0x7)
TYPE_B = const(0x8)
JD_THERMOCOUPLE_REG_TEMPERATURE = const(JD_REG_READING)
JD_THERMOCOUPLE_REG_MIN_TEMPERATURE = const(JD_REG_MIN_READING)
JD_THERMOCOUPLE_REG_MAX_TEMPERATURE = const(JD_REG_MAX_READING)

Просмотреть файл

@ -1 +1 @@
from .client import *
from .client import *

Просмотреть файл

@ -10,7 +10,6 @@ class ThermometerClient(Client):
def __init__(self, bus: Bus, role: str) -> None:
super().__init__(bus, JD_SERVICE_CLASS_THERMOMETER, JD_THERMOMETER_PACK_FORMATS, role)
@property
def temperature(self) -> Union[float, None]:
@ -51,5 +50,3 @@ class ThermometerClient(Client):
"""
reg = self.register(JD_THERMOMETER_REG_VARIANT)
return reg.value(0)

Просмотреть файл

@ -5,11 +5,14 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_THERMOMETER = const(0x1421bac7)
class ThermometerVariant(Enum):
OUTDOOR = const(0x1)
INDOOR = const(0x2)
BODY = const(0x3)
JD_THERMOMETER_REG_TEMPERATURE = const(JD_REG_READING)
JD_THERMOMETER_REG_MIN_TEMPERATURE = const(JD_REG_MIN_READING)
JD_THERMOMETER_REG_MAX_TEMPERATURE = const(JD_REG_MAX_READING)

Просмотреть файл

@ -5,7 +5,7 @@ class Transport:
# A base class for packet transports
on_receive: Optional[Callable[[bytes], None]] = None
# Callback to report a received packet to the bus
# Callback to report a received packet to the bus
def send(self, pkt: bytes) -> None:
# send a packet payload over the transport layer

Просмотреть файл

@ -29,9 +29,11 @@ HF2_CMD_JDS_CONFIG = 0x0020
HF2_CMD_JDS_SEND = 0x0021
HF2_EV_JDS_PACKET = 0x800020
class HF2Error(Exception):
pass
class HF2Transport(Transport):
def _write(self, buf: bytes):
frame = bytearray(64)
@ -47,7 +49,7 @@ class HF2Transport(Transport):
frame[0] = HF2_FLAG_CMDPKT_LAST
frame[0] |= l
frame[1:1+l] = buf[pos:pos+l]
self.serial.write(frame) # type: ignore
self.serial.write(frame) # type: ignore
pos += l
def _on_serial(self, buf: bytes, is_error: bool):
@ -68,7 +70,7 @@ class HF2Transport(Transport):
def _read_loop(self):
frames: list[bytes] = []
while True:
buf: bytes = self.serial.read(64) # type: ignore
buf: bytes = self.serial.read(64) # type: ignore
tp = buf[0] & HF2_FLAG_MASK
l = buf[0] & 63
frame = buf[1:1+l]
@ -107,11 +109,13 @@ class HF2Transport(Transport):
self._error("timeout for 0x%d" % cmd)
(seq2, status, info) = struct.unpack("<HBB", resp[0:4])
if seq != seq2:
self.log("packet out of sync (exp: %d, got: %d)" % (seq, seq2))
self.log("packet out of sync (exp: %d, got: %d)" %
(seq, seq2))
elif status == 0:
return resp[4:]
else:
self._error("bad status: %d (info=%d) for 0x%x" % (status, info, cmd))
self._error("bad status: %d (info=%d) for 0x%x" %
(status, info, cmd))
self._error("desync for 0x%x" % cmd)
def _connect(self):
@ -133,6 +137,5 @@ class HF2Transport(Transport):
self._connect()
if __name__ == "__main__":
hf2 = HF2Transport(sys.argv[1])

Просмотреть файл

@ -16,11 +16,11 @@ class WebSocketTransport(Transport):
def open(self) -> None:
self.ws = WebSocketApp(self.url,
on_open=self.on_open,
on_message=self.on_message,
on_error=self.on_error,
on_close=self.on_close)
t = threading.Thread(target=self.ws.run_forever) # type: ignore
on_open=self.on_open,
on_message=self.on_message,
on_error=self.on_error,
on_close=self.on_close)
t = threading.Thread(target=self.ws.run_forever) # type: ignore
t.start()
def send(self, pkt: bytes) -> None:

Просмотреть файл

@ -106,6 +106,7 @@ def short_id(longid: Union[bytes, str]):
chr(0x30 + (h // (26 * 26 * 10)) % 10)
)
def crc16(buf: bytes, start: int = 0, end: int = None):
if end is None:
end = len(buf)

Просмотреть файл

@ -5,10 +5,13 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_UV_INDEX = const(0x1f6e0d90)
class UvIndexVariant(Enum):
UVA_UVB = const(0x1)
VISIBLE_IR = const(0x2)
JD_UV_INDEX_REG_UV_INDEX = const(JD_REG_READING)
JD_UV_INDEX_REG_UV_INDEX_ERROR = const(JD_REG_READING_ERROR)
JD_UV_INDEX_REG_VARIANT = const(JD_REG_VARIANT)

Просмотреть файл

@ -5,16 +5,20 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_VERIFIED_TELEMETRY = const(0x2194841f)
class VerifiedTelemetryStatus(Enum):
UNKNOWN = const(0x0)
WORKING = const(0x1)
FAULTY = const(0x2)
class VerifiedTelemetryFingerprintType(Enum):
FALL_CURVE = const(0x1)
CURRENT_SENSE = const(0x2)
CUSTOM = const(0x3)
JD_VERIFIED_TELEMETRY_REG_TELEMETRY_STATUS = const(0x180)
JD_VERIFIED_TELEMETRY_REG_TELEMETRY_STATUS_INTERVAL = const(0x80)
JD_VERIFIED_TELEMETRY_REG_FINGERPRINT_TYPE = const(0x181)

Просмотреть файл

@ -5,11 +5,14 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_WATER_LEVEL = const(0x147b62ed)
class WaterLevelVariant(Enum):
RESISTIVE = const(0x1)
CONTACT_PHOTO_ELECTRIC = const(0x2)
NON_CONTACT_PHOTO_ELECTRIC = const(0x3)
JD_WATER_LEVEL_REG_LEVEL = const(JD_REG_READING)
JD_WATER_LEVEL_REG_VARIANT = const(JD_REG_VARIANT)
JD_WATER_LEVEL_PACK_FORMATS = {

Просмотреть файл

@ -5,11 +5,14 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_WEIGHT_SCALE = const(0x1f4d5040)
class WeightScaleVariant(Enum):
BODY = const(0x1)
FOOD = const(0x2)
JEWELRY = const(0x3)
JD_WEIGHT_SCALE_REG_WEIGHT = const(JD_REG_READING)
JD_WEIGHT_SCALE_REG_WEIGHT_ERROR = const(JD_REG_READING_ERROR)
JD_WEIGHT_SCALE_REG_ZERO_OFFSET = const(0x80)

Просмотреть файл

@ -5,6 +5,8 @@ from enum import Enum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_WIFI = const(0x18aae1fa)
class WifiAPFlags(Enum):
HAS_PASSWORD = const(0x1)
WPS = const(0x2)
@ -18,6 +20,7 @@ class WifiAPFlags(Enum):
IEEE_802_11AX = const(0x2000)
IEEE_802_LONG_RANGE = const(0x8000)
JD_WIFI_CMD_LAST_SCAN_RESULTS = const(0x80)
JD_WIFI_CMD_ADD_NETWORK = const(0x81)
JD_WIFI_CMD_RECONNECT = const(0x82)