aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 993da8b6e5f2069177ad281f5ea75ed2c1630a8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# HsMouse
Experimental control software for robotics, tested on Raspberry Pi 5.

## Features:
- Uses the
[`zeromq4-haskell`](https://hackage.haskell.org/package/zeromq4-haskell)
library for inter-process communication (IPC).
- The [`effectful`](https://hackage.haskell.org/package/effectful) library is
employed to constrain effects within monadic computations.
- The [`streamly`](https://hackage.haskell.org/package/streamly) library is
used to build modular data pipelines and stream data between pipeline elements
(e.g., `zmq client & processor & zmq server`).

## Build Instructions:
1. Install [`stack`](https://docs.haskellstack.org/en/stable/). It’s
recommended to use [`ghcup`](https://www.haskell.org/ghcup/) for installation.
2. Run `stack build` to compile the libraries and executables.

> Note: You may need to install system dependencies on your host first (e.g.,
> `libzmq`, `libgpiod`, etc.).

## Testing the Application
1. In one terminal, run `stack exec dummy-receiver` to start a ZMQ client that
waits for incoming pulses.
2. In another terminal, run `stack exec dummy-pulser` to send pulses to the
client.

You should see the following logs:
```
$> stack exec dummy-receiver
2025-01-12 21:27:02 INFO receiver/client: Initializing ZMQ client
2025-01-12 21:27:16 INFO receiver/receiver: Received pulse #1
2025-01-12 21:27:17 INFO receiver/receiver: Received pulse #2
[...]
2025-01-12 21:27:23 INFO receiver/receiver: Received pulse #8
2025-01-12 21:27:24 INFO receiver/receiver: Received pulse #9
```

```
$> stack exec dummy-pulser
2025-01-12 21:27:15 INFO pulser/server: Initializing ZMQ server
2025-01-12 21:27:16 INFO pulser/fsm/run: Sending pulse #1
2025-01-12 21:27:17 INFO pulser/fsm/run: Sending pulse #2
[...]
2025-01-12 21:27:23 INFO pulser/fsm/run: Sending pulse #8
2025-01-12 21:27:24 INFO pulser/fsm/run: Sending pulse #9
2025-01-12 21:27:25 ATTENTION pulser/fsm/run: Reached 10 pulses
2025-01-12 21:27:25 ATTENTION pulser/fsm: No state returned, exiting FSM
```

## GPIO and PWM Access Without Root:
To enable GPIO and PWM access without root privileges on the Raspberry Pi 5,
copy the files from the `./udev` directory into `/etc/udev/rules.d`. These
rules grant the `gpio` and `pwm` user groups permission to interface with the
respective subsystems.