🦘 cangaroo
Gleam bindings for the Excansock Elixir library.
gleam add cangaroo@1
import cangaroo
import cangaroo/bridge
import gleam/io
import gleam/result
pub fn main() {
let status = {
use socket <- result.try(
cangaroo.start() |> result.replace_error("start failed"),
)
use _ <- result.try(
cangaroo.open(socket, "vcan0") |> result.replace_error("open failed"),
)
io.println("Interface opened. Sending frame...")
let frame = bridge.new_frame(0x123, <<1, 2, 3, 4>>)
use _ <- result.try(
cangaroo.send(socket, frame) |> result.replace_error("send failed"),
)
io.println("Frame sent successfully")
Ok(Nil)
}
case status {
Ok(Nil) -> io.println("Finished")
Error(msg) -> io.println("Error: " <> msg)
}
}
Further documentation can be found at https://hexdocs.pm/cangaroo.
Development
gleam test # Run the tests