mirror of
https://github.com/bettercap/bettercap.git
synced 2024-11-08 06:30:13 -08:00
25 lines
442 B
Go
25 lines
442 B
Go
package can
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/dustin/go-humanize"
|
|
"go.einride.tech/can"
|
|
)
|
|
|
|
func (mod *CANModule) Inject(expr string) (err error) {
|
|
frame := can.Frame{}
|
|
if err := frame.UnmarshalString(expr); err != nil {
|
|
return err
|
|
}
|
|
|
|
mod.Info("injecting %s of CAN frame %d ...",
|
|
humanize.Bytes(uint64(frame.Length)), frame.ID)
|
|
|
|
if err := mod.send.TransmitFrame(context.Background(), frame); err != nil {
|
|
return err
|
|
}
|
|
|
|
return
|
|
}
|