gomksservo42c

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2023 License: Unlicense Imports: 4 Imported by: 0

README

A simple go wrapper for makerbase-mks/MKS-SERVO42C UART commands using a serial-package

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendChecksum

func AppendChecksum(input []uint8) []uint8

func CalcChecksum

func CalcChecksum(input []uint8) uint8

func CheckChecksum

func CheckChecksum(input []uint8) bool

Types

type Command

type Command uint8

use 1 byte

const (
	Command_ReadEncoderValue            Command = 0x30
	Command_ReadPulsesRecieved          Command = 0x33
	Command_ReadMotorShaftAngleError    Command = 0x39
	Command_ReadEnPinStatus             Command = 0x3A
	Command_ReleaseLockedShaftState     Command = 0x3D
	Command_ReadLockedShaftState        Command = 0x3E
	Command_RunCalibration              Command = 0x80
	Command_SetMotorType                Command = 0x81
	Command_SetWorkMode                 Command = 0x82
	Command_SetCurrent                  Command = 0x83
	Command_SetSubdivision              Command = 0x84
	Command_SetEnPinActive              Command = 0x85
	Command_SetDir                      Command = 0x86
	Command_SetAutomaticTurnOfScreen    Command = 0x87
	Command_SetLockedShaftState         Command = 0x88
	Command_SetSubdivisionInterpolation Command = 0x89
	Command_SetBaudRate                 Command = 0x8A
	Command_SetSlaveAddress             Command = 0x8B
	Command_RestoreDefaults             Command = 0x3F
	Command_SetZeroMode                 Command = 0x90
	Command_SetZero                     Command = 0x91
	Command_SetZeroSpeed                Command = 0x92
	Command_SetZeroModeDir              Command = 0x93
	Command_GoToZero                    Command = 0x94
	Command_SetKpPosition               Command = 0xA1
	Command_SetKiPosition               Command = 0xA2
	Command_SetKdPosition               Command = 0xA3
	Command_SetAcceleration             Command = 0xA4
	Command_SetMaximumTorque            Command = 0xA5
	Command_SetEnPinActiveUart          Command = 0xF3
	Command_RunMotor                    Command = 0xF6
	Command_StopMotor                   Command = 0xF7
	Command_UpdateStatusInF6Function    Command = 0xFF
	Command_RunMotorSteps               Command = 0xFD
)

type Service

type Service struct {
	// contains filtered or unexported fields
}

func CreateService

func CreateService(portName string, baud int) (*Service, error)

portname = /dev/COM45 opens a new serial connection for the service

func CreateServiceByConfig

func CreateServiceByConfig(config *serial.Config) (*Service, error)

func (*Service) Action_RunSteps added in v0.1.2

func (s *Service) Action_RunSteps(slave Slave, clockwise bool, speed uint8, pulses uint32) (bool, error)

func (*Service) SendCommand

func (s *Service) SendCommand(slave Slave, action Command, payload ...uint8) (bool, error)

returns if command was successfull, error is set if a error occured

type Slave

type Slave uint8

use 1 byte

const (
	Slave_0 Slave = 0xE0
	Slave_1 Slave = 0xE1
	Slave_2 Slave = 0xE2
	Slave_3 Slave = 0xE3
	Slave_4 Slave = 0xE4
	Slave_5 Slave = 0xE5
	Slave_6 Slave = 0xE6
	Slave_7 Slave = 0xE7
	Slave_8 Slave = 0xE8
	Slave_9 Slave = 0xE9
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL