Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More protocol docs and adjust program according to specs #9

Merged
merged 4 commits into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 64 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,76 @@ muuvctl get --follow

## Serial protocol

The protocol is not fully known.
The protocol seemst to be called TiMOTION F-Bus.
fujexo marked this conversation as resolved.
Show resolved Hide resolved
Baudrate is: `9600`
The following is known (possibly not everything that the controller can do):

The table sends the following for its position:
### RX
The controller in the table sends the following:
```c
uint8_t StartByte = 0x98;
uint8_t StartByte = 0x98;
uint8_t Param;
uint8_t Param;
uint8_t Data;
uint8_t Data;
```
b'\x98'
b'\x98'
b'\x03' <- can be b'\x00' as well
b'\x03' <- can be b'\x00' as well
b'O' <- position ord(pos)
b'O' <- position ord(pos)
`Param` is the following:
```c
STOPPED = 0x00;
SAVE_TRIGGED = 0x01;
MOVING = 0x03;
```
`Data` is normally the position of the table.

To move the table send the following:
### TX

You need to send the following struct to control it
```c
uint8_t StartByte = 0xD8;
uint8_t StartByte = 0xD8;
uint8_t Param;
uint8_t Command;
uint8_t Command;
```
b'f' > 102
b'\x00' > 0 (no move) 1 (up) 2(down)
b'\x00' > 0 (no move) 1 (up) 2(down)
b'\xd8' > 216
b'\xd8' > 216
Only known value for `Param` is `0x66` which is used in all commands.


`Command` is the following:
```c
STOP = 0x00;
DOWN = 0x01;
UP = 0x02;
RESET = 0x03;
POS1 = 0x04;
POS2 = 0x08;
POS3 = 0x10;
POS4 = 0x20;
SAVE = 0x40;
```
There is no known command yet to move the table to an specific position. You need to send up or down until the table reaches the desired position, then send stop.

#### TX Examples

* Move up: `0xD8, 0xD8, 0x66, 0x02, 0x02`
* Move down: `0xD8, 0xD8, 0x66, 0x01, 0x01`
* Stop: `0xD8, 0xD8, 0x66, 0x00, 0x00`
* Goto POS1: `0xD8, 0xD8, 0x66, 0x04, 0x04`
* Goto POS4: `0xD8, 0xD8, 0x66, 0x20, 0x20`
* Reset: `0xD8, 0xD8, 0x66, 0x03, 0x03`

##### Save
* Send min. 32x SAFE: `0xD8, 0xD8, 0x66, 0x40, 0x40`
* Optional: wait until table sends: `0x98, 0x98, 0x01, 0x01, POS, POS `
* Send 4x wanted POS, for POS1: `0xD8, 0xD8, 0x66, 0x04, 0x04`
* Send 1x STOP: `0xD8, 0xD8, 0x66, 0x00, 0x00`


#### Notes

There seems to be no way to move the table to an specific position. You need to send up or down until the table reaches the desired position, then send stop.




## Contributing

Expand Down
11 changes: 6 additions & 5 deletions muuvctl/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

logger = logging.getLogger(__name__)

MUUV_UP = [102, 2, 2, 216, 216]
MUUV_DOWN = [102, 1, 1, 216, 216]
MUUV_STOP = [102, 0, 0, 216, 216]
MUUV_UP = [0xD8, 0xD8, 0x66, 0x02, 0x02]
MUUV_DOWN = [0xD8, 0xD8, 0x66, 0x01, 0x01]
MUUV_STOP = [0xD8, 0xD8, 0x66, 0x00, 0x00]



def main():
Expand Down Expand Up @@ -51,13 +52,13 @@ def get_serial(port):


def search_pos(r):
if r not in [b"\x00", b"\x98", b"\x03"]:
if r not in [b"\x00", b"\x98", b"\x03", b"\x01"]:
return ord(r)
return False


@click.group()
@click.option("--port", default="/dev/ttyUSB3")
@click.option("--port", default="/dev/ttyUSB0")
@click.option("--debug/--no-debug", default=False)
@click.pass_context
def cli(ctx, debug, port):
Expand Down