mirror of
https://github.com/bettercap/bettercap
synced 2025-07-16 10:03:39 -07:00
new: implemented can.inject
This commit is contained in:
parent
5fe3ef3d52
commit
fd05df613e
3 changed files with 37 additions and 0 deletions
24
modules/can/can_inject.go
Normal file
24
modules/can/can_inject.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue