https://github.com/synapticon/motion-master-client-examples
TypeScript/JavaScript examples for interacting with Motion Master to configure and control SOMANET devices.
https://github.com/synapticon/motion-master-client-examples
ethercat javascript protobuf typescript websockets
Last synced: 5 months ago
JSON representation
TypeScript/JavaScript examples for interacting with Motion Master to configure and control SOMANET devices.
- Host: GitHub
- URL: https://github.com/synapticon/motion-master-client-examples
- Owner: synapticon
- Created: 2023-03-29T10:07:02.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-12-05T09:58:36.000Z (7 months ago)
- Last Synced: 2025-12-08T03:09:35.088Z (6 months ago)
- Topics: ethercat, javascript, protobuf, typescript, websockets
- Language: TypeScript
- Homepage: https://synapticon.github.io/oblac/motion-master-client/
- Size: 3.41 MB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Motion Master Client Examples
This repository provides TypeScript/JavaScript examples for interacting with Synapticon's Motion Master server application to configure and control SOMANET devices.
## Building
Clone this repository and install its dependencies:
```console
git clone https://github.com/synapticon/motion-master-client-examples.git
cd motion-master-client-examples
npm install
```
To transpile from TypeScript to JavaScript, use the following command:
```console
npm run build
```
The resulting JavaScript files will be located in the `dist` folder.
## Running
Before executing any scripts, ensure to set the `MOTION_MASTER_HOSTNAME` environment variable. For example, if the Motion Master process runs at `192.168.1.112`, you have two options:
1. Create a `.env` file in the repository root with `MOTION_MASTER_HOSTNAME=192.168.1.112`.
2. Run a script directly by setting the variable inline: `MOTION_MASTER_HOSTNAME=192.168.1.112 node ./dist/request/get-devices.rx.js`.
The advantage of using the `.env` file is that all scripts will consistently use the specified hostname without needing to set the variable each time.
To log all incoming and outgoing messages from Motion Master, set the `ROAR_LOG=true` environment variable when running your scripts.
Here's an example `.env` file configuration:
```sh
MOTION_MASTER_HOSTNAME=192.168.1.112
ROARR_LOG=true
```
Alternatively, you can run TypeScript files directly without transpiling using `ts-node`:
```console
npx ts-node ./src/request/get-devices.rx.ts
```
## Command line arguments
All commands associated with a specific device require the `--device-ref` option, along with other specific arguments. To view detailed help documentation for any command, use the `--help` option. For example:
```console
npx ts-node ./src/request/upload.ts --help
Usage: upload [options] [loadFromCache]
Arguments:
index object index in hexadecimal notation
subindex object subindex in hexadecimal notation
loadFromCache load parameter values from the Motion Master cache (choices: "true", "false", default: false)
Options:
-d, --device-ref position, address, or serial number (default: 0 position represents the first device in a network chain)
-t, --request-timeout after sending a request, how long will the client wait for Motion Master to send the status message back
-m, --message-id the message ID, which uniquely identifies the request, will be generated by the client library if not specified
-h, --help display help for command
```
Here is an example of how to read the drive temperature:
```console
npx ts-node ./src/request/upload.ts --device-ref=1 0x2031 0x01
```
## Monitoring
To monitor output data and save it to both stdout and a file (data.csv), use:
```console
node ./dist/start-monitoring.js --device-ref=1 | tee data.csv
```
## Developing
To watch `.ts` files for changes and automatically transpile, use:
```console
npm run watch
```