Skip to content

Commit

Permalink
jacscript -> devicescript
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Nov 30, 2022
1 parent 96011db commit cef34c8
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 63 deletions.
2 changes: 2 additions & 0 deletions jacdac/device_script_condition/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Autogenerated file.
from .client import DeviceScriptConditionClient # type: ignore
30 changes: 30 additions & 0 deletions jacdac/device_script_condition/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Autogenerated file. Do not edit.
from jacdac.bus import Bus, Client, EventHandlerFn, UnsubscribeFn
from .constants import *



class DeviceScriptConditionClient(Client):
"""
Conditions are synthetic services used to synchronize threads of executions of a DeviceScript VM.
Implements a client for the `DeviceScript Condition <https://microsoft.github.io/jacdac-docs/services/devicescriptcondition>`_ service.
"""

def __init__(self, bus: Bus, role: str) -> None:
super().__init__(bus, JD_SERVICE_CLASS_DEVICE_SCRIPT_CONDITION, JD_DEVICE_SCRIPT_CONDITION_PACK_FORMATS, role)


def on_signalled(self, handler: EventHandlerFn) -> UnsubscribeFn:
"""
Triggered by `signal` command.
"""
return self.on_event(JD_DEVICE_SCRIPT_CONDITION_EV_SIGNALLED, handler)


def signal(self, ) -> None:
"""
Triggers a `signalled` event.
"""
self.send_cmd_packed(JD_DEVICE_SCRIPT_CONDITION_CMD_SIGNAL, )

9 changes: 9 additions & 0 deletions jacdac/device_script_condition/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Autogenerated constants for DeviceScript Condition service
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_DEVICE_SCRIPT_CONDITION = const(0x1196796d)
JD_DEVICE_SCRIPT_CONDITION_CMD_SIGNAL = const(0x80)
JD_DEVICE_SCRIPT_CONDITION_EV_SIGNALLED = const(JD_EV_CHANGE)
JD_DEVICE_SCRIPT_CONDITION_PACK_FORMATS = {

}
2 changes: 2 additions & 0 deletions jacdac/device_script_manager/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Autogenerated file.
from .client import DeviceScriptManagerClient # type: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from typing import Optional


class JacscriptManagerClient(Client):
class DeviceScriptManagerClient(Client):
"""
Allows for deployment and control over Jacscript virtual machine.
Allows for deployment and control over DeviceScript virtual machine.
*
* Programs start automatically after device restart or uploading of new program.
* You can stop programs until next reset by setting the `running` register to `0`.
Expand All @@ -16,12 +16,12 @@ class JacscriptManagerClient(Client):
* * globals-changed pipe
* * breakpoint command
* * some performance monitoring?
Implements a client for the `Jacscript Manager <https://microsoft.github.io/jacdac-docs/services/jacscriptmanager>`_ service.
Implements a client for the `DeviceScript Manager <https://microsoft.github.io/jacdac-docs/services/devicescriptmanager>`_ service.
"""

def __init__(self, bus: Bus, role: str) -> None:
super().__init__(bus, JD_SERVICE_CLASS_JACSCRIPT_MANAGER, JD_JACSCRIPT_MANAGER_PACK_FORMATS, role)
super().__init__(bus, JD_SERVICE_CLASS_DEVICE_SCRIPT_MANAGER, JD_DEVICE_SCRIPT_MANAGER_PACK_FORMATS, role)


@property
Expand All @@ -31,11 +31,11 @@ def running(self) -> Optional[bool]:
To restart the program, stop it (write `0`), read back the register to make sure it's stopped,
start it, and read back.,
"""
return self.register(JD_JACSCRIPT_MANAGER_REG_RUNNING).bool_value()
return self.register(JD_DEVICE_SCRIPT_MANAGER_REG_RUNNING).bool_value()

@running.setter
def running(self, value: bool) -> None:
self.register(JD_JACSCRIPT_MANAGER_REG_RUNNING).set_values(value)
self.register(JD_DEVICE_SCRIPT_MANAGER_REG_RUNNING).set_values(value)


@property
Expand All @@ -44,11 +44,11 @@ def autostart(self) -> Optional[bool]:
Indicates wheather the program should be re-started upon `reboot()` or `panic()`.
Defaults to `true`.,
"""
return self.register(JD_JACSCRIPT_MANAGER_REG_AUTOSTART).bool_value()
return self.register(JD_DEVICE_SCRIPT_MANAGER_REG_AUTOSTART).bool_value()

@autostart.setter
def autostart(self, value: bool) -> None:
self.register(JD_JACSCRIPT_MANAGER_REG_AUTOSTART).set_values(value)
self.register(JD_DEVICE_SCRIPT_MANAGER_REG_AUTOSTART).set_values(value)


@property
Expand All @@ -57,40 +57,47 @@ def logging(self) -> Optional[bool]:
`log_message` reports are only sent when this is `true`.
It defaults to `false`.,
"""
return self.register(JD_JACSCRIPT_MANAGER_REG_LOGGING).bool_value()
return self.register(JD_DEVICE_SCRIPT_MANAGER_REG_LOGGING).bool_value()

@logging.setter
def logging(self, value: bool) -> None:
self.register(JD_JACSCRIPT_MANAGER_REG_LOGGING).set_values(value)
self.register(JD_DEVICE_SCRIPT_MANAGER_REG_LOGGING).set_values(value)


@property
def program_size(self) -> Optional[int]:
"""
The size of current program.,
"""
return self.register(JD_JACSCRIPT_MANAGER_REG_PROGRAM_SIZE).value()
return self.register(JD_DEVICE_SCRIPT_MANAGER_REG_PROGRAM_SIZE).value()

@property
def program_hash(self) -> Optional[int]:
"""
Return FNV1A hash of the current bytecode.,
"""
return self.register(JD_JACSCRIPT_MANAGER_REG_PROGRAM_HASH).value()
return self.register(JD_DEVICE_SCRIPT_MANAGER_REG_PROGRAM_HASH).value()

@property
def program_sha256(self) -> Optional[bytes]:
"""
Return 32-byte long SHA-256 hash of the current bytecode.,
"""
return self.register(JD_DEVICE_SCRIPT_MANAGER_REG_PROGRAM_SHA256).value()

def on_program_panic(self, handler: EventHandlerFn) -> UnsubscribeFn:
"""
Emitted when the program calls `panic(panic_code)` or `reboot()` (`panic_code == 0` in that case).
The byte offset in byte code of the call is given in `program_counter`.
The program will restart immediately when `panic_code == 0` or in a few seconds otherwise.
"""
return self.on_event(JD_JACSCRIPT_MANAGER_EV_PROGRAM_PANIC, handler)
return self.on_event(JD_DEVICE_SCRIPT_MANAGER_EV_PROGRAM_PANIC, handler)

def on_program_change(self, handler: EventHandlerFn) -> UnsubscribeFn:
"""
Emitted after bytecode of the program has changed.
"""
return self.on_event(JD_JACSCRIPT_MANAGER_EV_PROGRAM_CHANGE, handler)
return self.on_event(JD_DEVICE_SCRIPT_MANAGER_EV_PROGRAM_CHANGE, handler)


def deploy_bytecode(self, bytecode_size: int) -> None:
Expand All @@ -103,5 +110,5 @@ def deploy_bytecode(self, bytecode_size: int) -> None:
The data payloads, including the last one, should have a size that is a multiple of 32 bytes.
Thus, the initial bytecode_size also needs to be a multiple of 32.
"""
self.send_cmd_packed(JD_JACSCRIPT_MANAGER_CMD_DEPLOY_BYTECODE, bytecode_size)
self.send_cmd_packed(JD_DEVICE_SCRIPT_MANAGER_CMD_DEPLOY_BYTECODE, bytecode_size)

34 changes: 34 additions & 0 deletions jacdac/device_script_manager/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Autogenerated constants for DeviceScript Manager service
from enum import IntEnum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_DEVICE_SCRIPT_MANAGER = const(0x1134ea2b)


class DeviceScriptManagerMessageFlags(IntEnum):
TO_BE_CONTINUED = const(0x1)


JD_DEVICE_SCRIPT_MANAGER_CMD_DEPLOY_BYTECODE = const(0x80)
JD_DEVICE_SCRIPT_MANAGER_CMD_READ_BYTECODE = const(0x81)
JD_DEVICE_SCRIPT_MANAGER_CMD_LOG_MESSAGE = const(0x82)
JD_DEVICE_SCRIPT_MANAGER_REG_RUNNING = const(0x80)
JD_DEVICE_SCRIPT_MANAGER_REG_AUTOSTART = const(0x81)
JD_DEVICE_SCRIPT_MANAGER_REG_LOGGING = const(0x82)
JD_DEVICE_SCRIPT_MANAGER_REG_PROGRAM_SIZE = const(0x180)
JD_DEVICE_SCRIPT_MANAGER_REG_PROGRAM_HASH = const(0x181)
JD_DEVICE_SCRIPT_MANAGER_REG_PROGRAM_SHA256 = const(0x182)
JD_DEVICE_SCRIPT_MANAGER_EV_PROGRAM_PANIC = const(0x80)
JD_DEVICE_SCRIPT_MANAGER_EV_PROGRAM_CHANGE = const(JD_EV_CHANGE)
JD_DEVICE_SCRIPT_MANAGER_PACK_FORMATS = {
JD_DEVICE_SCRIPT_MANAGER_CMD_DEPLOY_BYTECODE: "u32",
JD_DEVICE_SCRIPT_MANAGER_CMD_READ_BYTECODE: "b[12]",
JD_DEVICE_SCRIPT_MANAGER_CMD_LOG_MESSAGE: "u8 u8 s",
JD_DEVICE_SCRIPT_MANAGER_REG_RUNNING: "u8",
JD_DEVICE_SCRIPT_MANAGER_REG_AUTOSTART: "u8",
JD_DEVICE_SCRIPT_MANAGER_REG_LOGGING: "u8",
JD_DEVICE_SCRIPT_MANAGER_REG_PROGRAM_SIZE: "u32",
JD_DEVICE_SCRIPT_MANAGER_REG_PROGRAM_HASH: "u32",
JD_DEVICE_SCRIPT_MANAGER_REG_PROGRAM_SHA256: "b[32]",
JD_DEVICE_SCRIPT_MANAGER_EV_PROGRAM_PANIC: "u32 u32"
}
2 changes: 0 additions & 2 deletions jacdac/jacscript_condition/__init__.py

This file was deleted.

9 changes: 0 additions & 9 deletions jacdac/jacscript_condition/constants.py

This file was deleted.

2 changes: 0 additions & 2 deletions jacdac/jacscript_manager/__init__.py

This file was deleted.

32 changes: 0 additions & 32 deletions jacdac/jacscript_manager/constants.py

This file was deleted.

2 changes: 1 addition & 1 deletion jacdac/timeseries_aggregator/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
JD_TIMESERIES_AGGREGATOR_CMD_UPDATE: "f64 s",
JD_TIMESERIES_AGGREGATOR_CMD_SET_WINDOW: "u32 s",
JD_TIMESERIES_AGGREGATOR_CMD_SET_UPLOAD: "u8 s",
JD_TIMESERIES_AGGREGATOR_CMD_STORED: "u32 f64 f64 f64 u32 u32 s",
JD_TIMESERIES_AGGREGATOR_CMD_STORED: "u32 b[4] f64 f64 f64 u32 u32 s",
JD_TIMESERIES_AGGREGATOR_REG_NOW: "u32",
JD_TIMESERIES_AGGREGATOR_REG_FAST_START: "u8",
JD_TIMESERIES_AGGREGATOR_REG_DEFAULT_WINDOW: "u32",
Expand Down
9 changes: 8 additions & 1 deletion jacdac/vibration_motor/client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Autogenerated file. Do not edit.
from jacdac.bus import Bus, Client
from .constants import *

from typing import Optional


class VibrationMotorClient(Client):
Expand All @@ -15,4 +15,11 @@ def __init__(self, bus: Bus, role: str) -> None:
super().__init__(bus, JD_SERVICE_CLASS_VIBRATION_MOTOR, JD_VIBRATION_MOTOR_PACK_FORMATS, role)


@property
def max_vibrations(self) -> Optional[int]:
"""
(Optional) The maximum number of vibration sequences supported in a single packet.,
"""
return self.register(JD_VIBRATION_MOTOR_REG_MAX_VIBRATIONS).value()


4 changes: 3 additions & 1 deletion jacdac/vibration_motor/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from jacdac.constants import *
JD_SERVICE_CLASS_VIBRATION_MOTOR = const(0x183fc4a2)
JD_VIBRATION_MOTOR_CMD_VIBRATE = const(0x80)
JD_VIBRATION_MOTOR_REG_MAX_VIBRATIONS = const(0x180)
JD_VIBRATION_MOTOR_PACK_FORMATS = {
JD_VIBRATION_MOTOR_CMD_VIBRATE: "r: u8 u0.8"
JD_VIBRATION_MOTOR_CMD_VIBRATE: "r: u8 u0.8",
JD_VIBRATION_MOTOR_REG_MAX_VIBRATIONS: "u8"
}

0 comments on commit cef34c8

Please sign in to comment.