Documentation
¶
Index ¶
- Constants
- func EndCodeToMsg(u uint16) string
- type BCDBadDigitError
- type BCDOverflowError
- type ClientClosedError
- type ClientClosingError
- type DeviceAddress
- type EmptyPlcUDPAddress
- type EmptyWriteRequestError
- type EndCodeError
- type Header
- type IncompatibleMemoryAreaError
- type Logger
- type ResponseLengthError
- type ResponseTimeoutError
- type UDPAddress
- type UDPClient
- func (c *UDPClient) Close()
- func (c *UDPClient) ReadBits(memoryArea byte, address uint16, bitOffset byte, readCount uint16) ([]bool, error)
- func (c *UDPClient) ReadBytes(memoryArea byte, address uint16, readCount uint16) ([]byte, error)
- func (c *UDPClient) ReadClock() (t *time.Time, err error)
- func (c *UDPClient) ReadString(memoryArea byte, address uint16, readCount uint16) (string, error)
- func (c *UDPClient) ReadWords(memoryArea byte, address uint16, readCount uint16) ([]uint16, error)
- func (c *UDPClient) ResetBit(memoryArea byte, address uint16, bitOffset byte) error
- func (c *UDPClient) SetBit(memoryArea byte, address uint16, bitOffset byte) error
- func (c *UDPClient) SetByteOrder(o binary.ByteOrder)
- func (c *UDPClient) SetIgnoreErrorCodes(codes []uint16)
- func (c *UDPClient) SetReadGoroutineNum(count uint8)
- func (c *UDPClient) SetReadPacketErrorLogger(l Logger)
- func (c *UDPClient) SetShowPacket(show bool)
- func (c *UDPClient) SetTimeoutMs(t uint)
- func (c *UDPClient) ToggleBit(memoryArea byte, address uint16, bitOffset byte) error
- func (c *UDPClient) WriteBits(memoryArea byte, address uint16, bitOffset byte, data []bool) error
- func (c *UDPClient) WriteBytes(memoryArea byte, address uint16, b []byte) error
- func (c *UDPClient) WriteString(memoryArea byte, address uint16, s string) error
- func (c *UDPClient) WriteWords(memoryArea byte, address uint16, data []uint16) error
- type UDPServer
Constants ¶
const ( // CommandCodeMemoryAreaRead Command code: IO memory area read CommandCodeMemoryAreaRead uint16 = 0x0101 // CommandCodeMemoryAreaWrite Command code: IO memory area write CommandCodeMemoryAreaWrite uint16 = 0x0102 // CommandCodeMemoryAreaFill Command code: IO memory area fill CommandCodeMemoryAreaFill uint16 = 0x0103 // CommandCodeMultipleMemoryAreaRead Command code: IO memory area multiple read CommandCodeMultipleMemoryAreaRead uint16 = 0x0104 // CommandCodeMemoryAreaTransfer Command code: IO memory area transfer CommandCodeMemoryAreaTransfer uint16 = 0x0105 // CommandCodeParameterAreaRead Command code: Parameter area read CommandCodeParameterAreaRead uint16 = 0x0201 // CommandCodeParameterAreaWrite Command code: Parameter area write CommandCodeParameterAreaWrite uint16 = 0x0202 // CommandCodeParameterAreaClear Command code: Parameter area clear CommandCodeParameterAreaClear uint16 = 0x0203 // CommandCodeProgramAreaRead Command code: Program area read CommandCodeProgramAreaRead uint16 = 0x0301 // CommandCodeProgramAreaWrite Command code: Program area write CommandCodeProgramAreaWrite uint16 = 0x0302 // CommandCodeProgramAreaClear Command code: Program area clear CommandCodeProgramAreaClear uint16 = 0x0303 // CommandCodeRun Command code: Set operating mode to run CommandCodeRun uint16 = 0x0401 // CommandCodeStop Command code: Set operating mode to stop CommandCodeStop uint16 = 0x0402 // CommandCodeCPUUnitDataRead Command code: CPU unit data read CommandCodeCPUUnitDataRead uint16 = 0x0501 // CommandCodeConnectionDataRead Command code: connection data read CommandCodeConnectionDataRead uint16 = 0x0502 // CommandCodeCPUUnitStatusRead Command code: CPU unit status read CommandCodeCPUUnitStatusRead uint16 = 0x0601 // CommandCodeCycleTimeRead Command code: cycle time read CommandCodeCycleTimeRead uint16 = 0x0620 // CommandCodeClockRead Command code: clock read CommandCodeClockRead uint16 = 0x701 // CommandCodeClockWrite Command code: clock write CommandCodeClockWrite uint16 = 0x702 // CommandCodeMessageReadClear Command code: message read/clear CommandCodeMessageReadClear uint16 = 0x0920 // CommandCodeAccessRightAcquire Command code: access right acquire CommandCodeAccessRightAcquire uint16 = 0x0c01 // CommandCodeAccessRightForcedAcquire Command code: accress right forced acquire CommandCodeAccessRightForcedAcquire uint16 = 0x0c02 // CommandCodeAccessRightRelease Command code: access right release CommandCodeAccessRightRelease uint16 = 0x0c03 // CommandCodeErrorClear Command code: error clear CommandCodeErrorClear uint16 = 0x2101 // CommandCodeErrorLogRead Command code: error log read CommandCodeErrorLogRead uint16 = 0x2102 // CommandCodeErrorLogClear Command code: error log clear CommandCodeErrorLogClear uint16 = 0x2103 // CommandCodeFINSWriteAccessLogRead Command code: FINS write access log read CommandCodeFINSWriteAccessLogRead uint16 = 0x2140 // CommandCodeFINSWriteAccessLogWrite Command code: FINS write access log write CommandCodeFINSWriteAccessLogWrite uint16 = 0x2141 // CommandCodeFileNameRead Command code: file name read CommandCodeFileNameRead uint16 = 0x2101 // CommandCodeSingleFileRead Command code: file read CommandCodeSingleFileRead uint16 = 0x2102 // CommandCodeSingleFileWrite Command code: file write CommandCodeSingleFileWrite uint16 = 0x2103 // CommandCodeFileMemoryFormat Command code: file memory format CommandCodeFileMemoryFormat uint16 = 0x2104 // CommandCodeFileDelete Command code: file delete CommandCodeFileDelete uint16 = 0x2105 // CommandCodeFileCopy Command code: file copy CommandCodeFileCopy uint16 = 0x2107 // CommandCodeFileNameChange Command code: file name change CommandCodeFileNameChange uint16 = 0x2108 // CommandCodeMemoryAreaFileTransfer Command code: memory area file transfer CommandCodeMemoryAreaFileTransfer uint16 = 0x210a // CommandCodeParameterAreaFileTransfer Command code: parameter area file transfer CommandCodeParameterAreaFileTransfer uint16 = 0x210b // CommandCodeProgramAreaFileTransfer Command code: program area file transfer CommandCodeProgramAreaFileTransfer uint16 = 0x210b // CommandCodeDirectoryCreateDelete Command code: directory create/delete CommandCodeDirectoryCreateDelete uint16 = 0x2115 // CommandCodeMemoryCassetteTransfer Command code: memory cassette transfer (CP1H and CP1L CPU units only) CommandCodeMemoryCassetteTransfer uint16 = 0x2120 // CommandCodeForcedSetReset Command code: forced set/reset CommandCodeForcedSetReset uint16 = 0x2301 // CommandCodeForcedSetResetCancel Command code: forced set/reset cancel CommandCodeForcedSetResetCancel uint16 = 0x2302 // CommandCodeConvertToCompoWayFCommand Command code: convert to CompoWay/F command CommandCodeConvertToCompoWayFCommand uint16 = 0x2803 // CommandCodeConvertToModbusRTUCommand Command code: convert to Modbus-RTU command CommandCodeConvertToModbusRTUCommand uint16 = 0x2804 // CommandCodeConvertToModbusASCIICommand Command code: convert to Modbus-ASCII command CommandCodeConvertToModbusASCIICommand uint16 = 0x2805 )
const ( // EndCodeNormalCompletion End code: normal completion EndCodeNormalCompletion uint16 = 0x0000 // EndCodeServiceInterrupted End code: normal completion; service was interrupted EndCodeServiceInterrupted uint16 = 0x0001 // EndCodeLocalNodeNotInNetwork End code: local node error; local node not in network EndCodeLocalNodeNotInNetwork uint16 = 0x0101 // EndCodeTokenTimeout End code: local node error; token timeout EndCodeTokenTimeout uint16 = 0x0102 // EndCodeRetriesFailed End code: local node error; retries failed EndCodeRetriesFailed uint16 = 0x0103 // EndCodeTooManySendFrames End code: local node error; too many send frames EndCodeTooManySendFrames uint16 = 0x0104 // EndCodeNodeAddressRangeError End code: local node error; node address range error EndCodeNodeAddressRangeError uint16 = 0x0105 // EndCodeNodeAddressRangeDuplication End code: local node error; node address range duplication EndCodeNodeAddressRangeDuplication uint16 = 0x0106 // EndCodeDestinationNodeNotInNetwork End code: destination node error; destination node not in network EndCodeDestinationNodeNotInNetwork uint16 = 0x0201 // EndCodeUnitMissing End code: destination node error; unit missing EndCodeUnitMissing uint16 = 0x0202 // EndCodeThirdNodeMissing End code: destination node error; third node missing EndCodeThirdNodeMissing uint16 = 0x0203 // EndCodeDestinationNodeBusy End code: destination node error; destination node busy EndCodeDestinationNodeBusy uint16 = 0x0204 // EndCodeResponseTimeout End code: destination node error; response timeout EndCodeResponseTimeout uint16 = 0x0205 // EndCodeCommunicationsControllerError End code: controller error; communication controller error EndCodeCommunicationsControllerError uint16 = 0x0301 // EndCodeCPUUnitError End code: controller error; CPU unit error EndCodeCPUUnitError uint16 = 0x0302 // EndCodeControllerError End code: controller error; controller error EndCodeControllerError uint16 = 0x0303 // EndCodeUnitNumberError End code: controller error; unit number error EndCodeUnitNumberError uint16 = 0x0304 // EndCodeUndefinedCommand End code: service unsupported; undefined command EndCodeUndefinedCommand uint16 = 0x0401 // EndCodeNotSupportedByModelVersion End code: service unsupported; not supported by model version EndCodeNotSupportedByModelVersion uint16 = 0x0402 // EndCodeDestinationAddressSettingError End code: routing table error; destination address setting error EndCodeDestinationAddressSettingError uint16 = 0x0501 // EndCodeNoRoutingTables End code: routing table error; no routing tables EndCodeNoRoutingTables uint16 = 0x0502 // EndCodeRoutingTableError End code: routing table error; routing table error EndCodeRoutingTableError uint16 = 0x0503 // EndCodeTooManyRelays End code: routing table error; too many relays EndCodeTooManyRelays uint16 = 0x0504 // EndCodeCommandTooLong End code: command format error; command too long EndCodeCommandTooLong uint16 = 0x1001 // EndCodeCommandTooShort End code: command format error; command too short EndCodeCommandTooShort uint16 = 0x1002 // EndCodeElementsDataDontMatch End code: command format error; elements/data don't match EndCodeElementsDataDontMatch uint16 = 0x1003 // EndCodeCommandFormatError End code: command format error; command format error EndCodeCommandFormatError uint16 = 0x1004 // EndCodeHeaderError End code: command format error; header error EndCodeHeaderError uint16 = 0x1005 // EndCodeAreaClassificationMissing End code: parameter error; classification missing EndCodeAreaClassificationMissing uint16 = 0x1101 // EndCodeAccessSizeError End code: parameter error; access size error EndCodeAccessSizeError uint16 = 0x1102 // EndCodeAddressRangeError End code: parameter error; address range error EndCodeAddressRangeError uint16 = 0x1103 // EndCodeAddressRangeExceeded End code: parameter error; address range exceeded EndCodeAddressRangeExceeded uint16 = 0x1104 // EndCodeProgramMissing End code: parameter error; program missing EndCodeProgramMissing uint16 = 0x1106 // EndCodeRelationalError End code: parameter error; relational error EndCodeRelationalError uint16 = 0x1109 // EndCodeDuplicateDataAccess End code: parameter error; duplicate data access EndCodeDuplicateDataAccess uint16 = 0x110a // EndCodeResponseTooBig End code: parameter error; response too big EndCodeResponseTooBig uint16 = 0x110b // EndCodeParameterError End code: parameter error EndCodeParameterError uint16 = 0x110c // EndCodeReadNotPossibleProtected End code: read not possible; protected EndCodeReadNotPossibleProtected uint16 = 0x2002 // EndCodeReadNotPossibleTableMissing End code: read not possible; table missing EndCodeReadNotPossibleTableMissing uint16 = 0x2003 // EndCodeReadNotPossibleDataMissing End code: read not possible; data missing EndCodeReadNotPossibleDataMissing uint16 = 0x2004 // EndCodeReadNotPossibleProgramMissing End code: read not possible; program missing EndCodeReadNotPossibleProgramMissing uint16 = 0x2005 // EndCodeReadNotPossibleFileMissing End code: read not possible; file missing EndCodeReadNotPossibleFileMissing uint16 = 0x2006 // EndCodeReadNotPossibleDataMismatch End code: read not possible; data mismatch EndCodeReadNotPossibleDataMismatch uint16 = 0x2007 // EndCodeWriteNotPossibleReadOnly End code: write not possible; read only EndCodeWriteNotPossibleReadOnly uint16 = 0x2101 // EndCodeWriteNotPossibleProtected End code: write not possible; write protected EndCodeWriteNotPossibleProtected uint16 = 0x2102 // EndCodeWriteNotPossibleCannotRegister End code: write not possible; cannot register EndCodeWriteNotPossibleCannotRegister uint16 = 0x2103 // EndCodeWriteNotPossibleProgramMissing End code: write not possible; program missing EndCodeWriteNotPossibleProgramMissing uint16 = 0x2105 // EndCodeWriteNotPossibleFileMissing End code: write not possible; file missing EndCodeWriteNotPossibleFileMissing uint16 = 0x2106 // EndCodeWriteNotPossibleFileNameAlreadyExists End code: write not possible; file name already exists EndCodeWriteNotPossibleFileNameAlreadyExists uint16 = 0x2107 // EndCodeWriteNotPossibleCannotChange End code: write not possible; cannot change EndCodeWriteNotPossibleCannotChange uint16 = 0x2108 // EndCodeNotExecutableInCurrentModeNotPossibleDuringExecution End code: not executeable in current mode during execution EndCodeNotExecutableInCurrentModeNotPossibleDuringExecution uint16 = 0x2201 // EndCodeNotExecutableInCurrentModeNotPossibleWhileRunning End code: not executeable in current mode while running EndCodeNotExecutableInCurrentModeNotPossibleWhileRunning uint16 = 0x2202 // EndCodeNotExecutableInCurrentModeWrongPLCModeInProgram End code: not executeable in current mode; PLC is in PROGRAM mode EndCodeNotExecutableInCurrentModeWrongPLCModeInProgram uint16 = 0x2203 // EndCodeNotExecutableInCurrentModeWrongPLCModeInDebug End code: not executeable in current mode; PLC is in DEBUG mode EndCodeNotExecutableInCurrentModeWrongPLCModeInDebug uint16 = 0x2204 // EndCodeNotExecutableInCurrentModeWrongPLCModeInMonitor End code: not executeable in current mode; PLC is in MONITOR mode EndCodeNotExecutableInCurrentModeWrongPLCModeInMonitor uint16 = 0x2205 // EndCodeNotExecutableInCurrentModeWrongPLCModeInRun End code: not executeable in current mode; PLC is in RUN mode EndCodeNotExecutableInCurrentModeWrongPLCModeInRun uint16 = 0x2206 // EndCodeNotExecutableInCurrentModeSpecifiedNodeNotPollingNode End code: not executeable in current mode; specified node is not polling node EndCodeNotExecutableInCurrentModeSpecifiedNodeNotPollingNode uint16 = 0x2207 // EndCodeNotExecutableInCurrentModeStepCannotBeExecuted End code: not executeable in current mode; step cannot be executed EndCodeNotExecutableInCurrentModeStepCannotBeExecuted uint16 = 0x2208 // EndCodeNoSuchDeviceFileDeviceMissing End code: no such device; file device missing EndCodeNoSuchDeviceFileDeviceMissing uint16 = 0x2301 // EndCodeNoSuchDeviceMemoryMissing End code: no such device; memory missing EndCodeNoSuchDeviceMemoryMissing uint16 = 0x2302 // EndCodeNoSuchDeviceClockMissing End code: no such device; clock missing EndCodeNoSuchDeviceClockMissing uint16 = 0x2303 // EndCodeCannotStartStopTableMissing End code: cannot start/stop; table missing EndCodeCannotStartStopTableMissing uint16 = 0x2401 // EndCodeUnitErrorMemoryError End code: unit error; memory error EndCodeUnitErrorMemoryError uint16 = 0x2502 // EndCodeUnitErrorIOError End code: unit error; IO error EndCodeUnitErrorIOError uint16 = 0x2503 // EndCodeUnitErrorTooManyIOPoints End code: unit error; too many IO points EndCodeUnitErrorTooManyIOPoints uint16 = 0x2504 // EndCodeUnitErrorCPUBusError End code: unit error; CPU bus error EndCodeUnitErrorCPUBusError uint16 = 0x2505 // EndCodeUnitErrorIODuplication End code: unit error; IO duplication EndCodeUnitErrorIODuplication uint16 = 0x2506 // EndCodeUnitErrorIOBusError End code: unit error; IO bus error EndCodeUnitErrorIOBusError uint16 = 0x2507 // EndCodeUnitErrorSYSMACBUS2Error End code: unit error; SYSMAC BUS/2 error EndCodeUnitErrorSYSMACBUS2Error uint16 = 0x2509 // EndCodeUnitErrorCPUBusUnitError End code: unit error; CPU bus unit error EndCodeUnitErrorCPUBusUnitError uint16 = 0x250a // EndCodeUnitErrorSYSMACBusNumberDuplication End code: unit error; SYSMAC bus number duplication EndCodeUnitErrorSYSMACBusNumberDuplication uint16 = 0x250d // EndCodeUnitErrorMemoryStatusError End code: unit error; memory status error EndCodeUnitErrorMemoryStatusError uint16 = 0x250f // EndCodeUnitErrorSYSMACBusTerminatorMissing End code: unit error; SYSMAC bus terminator missing EndCodeUnitErrorSYSMACBusTerminatorMissing uint16 = 0x2510 // EndCodeCommandErrorNoProtection End code: command error; no protection EndCodeCommandErrorNoProtection uint16 = 0x2601 // EndCodeCommandErrorIncorrectPassword End code: command error; incorrect password EndCodeCommandErrorIncorrectPassword uint16 = 0x2602 // EndCodeCommandErrorProtected End code: command error; protected EndCodeCommandErrorProtected uint16 = 0x2604 // EndCodeCommandErrorServiceAlreadyExecuting End code: command error; service already executing EndCodeCommandErrorServiceAlreadyExecuting uint16 = 0x2605 // EndCodeCommandErrorServiceStopped End code: command error; service stopped EndCodeCommandErrorServiceStopped uint16 = 0x2606 // EndCodeCommandErrorNoExecutionRight End code: command error; no execution right EndCodeCommandErrorNoExecutionRight uint16 = 0x2607 // EndCodeCommandErrorSettingsNotComplete End code: command error; settings not complete EndCodeCommandErrorSettingsNotComplete uint16 = 0x2608 // EndCodeCommandErrorNecessaryItemsNotSet End code: command error; necessary items not set EndCodeCommandErrorNecessaryItemsNotSet uint16 = 0x2609 // EndCodeCommandErrorNumberAlreadyDefined End code: command error; number already defined EndCodeCommandErrorNumberAlreadyDefined uint16 = 0x260a // EndCodeCommandErrorErrorWillNotClear End code: command error; error will not clear EndCodeCommandErrorErrorWillNotClear uint16 = 0x260b // EndCodeAccessWriteErrorNoAccessRight End code: access write error; no access right EndCodeAccessWriteErrorNoAccessRight uint16 = 0x3001 // EndCodeAbortServiceAborted End code: abort; service aborted EndCodeAbortServiceAborted uint16 = 0x4001 )
Data taken from Omron document Cat. No. W342-E1-15, pages 155-161
const ( // MessageTypeCommand Command message type MessageTypeCommand uint8 = iota // MessageTypeResponse Response message type MessageTypeResponse uint8 = iota )
const ( // MemoryAreaCIOBit Memory area: CIO area; bit MemoryAreaCIOBit byte = 0x30 // MemoryAreaWRBit Memory area: work area; bit MemoryAreaWRBit byte = 0x31 // MemoryAreaHRBit Memory area: holding area; bit MemoryAreaHRBit byte = 0x32 // MemoryAreaARBit Memory area: axuillary area; bit MemoryAreaARBit byte = 0x33 // MemoryAreaCIOWord Memory area: CIO area; word MemoryAreaCIOWord byte = 0xb0 // MemoryAreaWRWord Memory area: work area; word MemoryAreaWRWord byte = 0xb1 // MemoryAreaHRWord Memory area: holding area; word MemoryAreaHRWord byte = 0xb2 // MemoryAreaARWord Memory area: auxillary area; word MemoryAreaARWord byte = 0xb3 // MemoryAreaTimerCounterCompletionFlag Memory area: counter completion flag MemoryAreaTimerCounterCompletionFlag byte = 0x09 // MemoryAreaTimerCounterPV Memory area: counter PV MemoryAreaTimerCounterPV byte = 0x89 // MemoryAreaDMBit Memory area: data area; bit MemoryAreaDMBit byte = 0x02 // MemoryAreaDMWord Memory area: data area; word MemoryAreaDMWord byte = 0x82 // MemoryAreaTaskBit Memory area: task flags; bit MemoryAreaTaskBit byte = 0x06 // MemoryAreaTaskStatus Memory area: task flags; status MemoryAreaTaskStatus byte = 0x46 // MemoryAreaIndexRegisterPV Memory area: CIO bit MemoryAreaIndexRegisterPV byte = 0xdc // MemoryAreaDataRegisterPV Memory area: CIO bit MemoryAreaDataRegisterPV byte = 0xbc // MemoryAreaClockPulsesConditionFlagsBit Memory area: CIO bit MemoryAreaClockPulsesConditionFlagsBit byte = 0x07 )
const DmAreaSize = 32768
Variables ¶
This section is empty.
Functions ¶
func EndCodeToMsg ¶
Types ¶
type BCDBadDigitError ¶
type BCDBadDigitError struct {
// contains filtered or unexported fields
}
func (BCDBadDigitError) Error ¶
func (e BCDBadDigitError) Error() string
type BCDOverflowError ¶
type BCDOverflowError struct{}
func (BCDOverflowError) Error ¶
func (e BCDOverflowError) Error() string
type ClientClosedError ¶
type ClientClosedError struct {
}
func (ClientClosedError) Error ¶
func (ClientClosedError) Error() string
func (ClientClosedError) Unwrap ¶
func (ClientClosedError) Unwrap() error
type ClientClosingError ¶
type ClientClosingError struct {
}
func (ClientClosingError) Error ¶
func (ClientClosingError) Error() string
type DeviceAddress ¶
type DeviceAddress struct {
// contains filtered or unexported fields
}
DeviceAddress A FINS device address
type EmptyPlcUDPAddress ¶
type EmptyPlcUDPAddress struct{}
func (EmptyPlcUDPAddress) Error ¶
func (e EmptyPlcUDPAddress) Error() string
type EmptyWriteRequestError ¶
type EmptyWriteRequestError struct {
}
func (EmptyWriteRequestError) Error ¶
func (EmptyWriteRequestError) Error() string
type EndCodeError ¶
type EndCodeError struct {
// contains filtered or unexported fields
}
func (EndCodeError) EndCode ¶
func (e EndCodeError) EndCode() uint16
func (EndCodeError) Error ¶
func (e EndCodeError) Error() string
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
Header A FINS frame header
type IncompatibleMemoryAreaError ¶
type IncompatibleMemoryAreaError struct {
// contains filtered or unexported fields
}
func (IncompatibleMemoryAreaError) Error ¶
func (e IncompatibleMemoryAreaError) Error() string
type ResponseLengthError ¶
type ResponseLengthError struct {
// contains filtered or unexported fields
}
func (ResponseLengthError) Error ¶
func (e ResponseLengthError) Error() string
type ResponseTimeoutError ¶
type ResponseTimeoutError struct {
// contains filtered or unexported fields
}
func (ResponseTimeoutError) Error ¶
func (e ResponseTimeoutError) Error() string
func (ResponseTimeoutError) Temporary ¶
func (e ResponseTimeoutError) Temporary() bool
func (ResponseTimeoutError) Timeout ¶
func (e ResponseTimeoutError) Timeout() bool
type UDPAddress ¶
type UDPAddress struct {
// contains filtered or unexported fields
}
UDPAddress A full device address
func NewUDPAddress ¶
func NewUDPAddress(ip string, port int, network, node, unit byte) UDPAddress
type UDPClient ¶
type UDPClient struct {
// contains filtered or unexported fields
}
UDPClient Omron FINS client this is concurrent safe
func NewUDPClient ¶
func NewUDPClient(localAddr, plcAddr UDPAddress) (*UDPClient, error)
NewUDPClient creates a new Omron FINS client
func (*UDPClient) ReadBits ¶
func (c *UDPClient) ReadBits(memoryArea byte, address uint16, bitOffset byte, readCount uint16) ([]bool, error)
ReadBits Reads bits from the PLC data area note: readCount is count of bool, so len(return) is readCount
func (*UDPClient) ReadBytes ¶
ReadBytes Reads bytes from the PLC data area note: readCount is count of uint16, not count of byte, so len(return) is 2*readCount
func (*UDPClient) ReadString ¶
ReadString Reads a string from the PLC data area note: readCount is count of uint16, not len of string or count of byte
func (*UDPClient) ResetBit ¶
ResetBit Resets a bit in the PLC data area Example:
ResetBit(A, 100, 0) will set A100.0=0 [00 01] -> [00 00] ResetBit(A, 100, 16) will set A101.0=0 [00 00 00 01] -> [00 00 00 00]
func (*UDPClient) SetByteOrder ¶
SetByteOrder Set byte order Default value: binary.BigEndian
func (*UDPClient) SetIgnoreErrorCodes ¶ added in v0.0.2
SetIgnoreErrorCodes Set ignore error codes
func (*UDPClient) SetReadGoroutineNum ¶
SetReadGoroutineNum Note: won't stop running goroutine
func (*UDPClient) SetReadPacketErrorLogger ¶
func (c *UDPClient) SetReadPacketErrorLogger(l Logger)
SetReadPacketErrorLogger read packet run background, we need a Logger to print error Default print error to stdout
func (*UDPClient) SetShowPacket ¶
func (c *UDPClient) SetShowPacket(show bool)
func (*UDPClient) SetTimeoutMs ¶
SetTimeoutMs Set response timeout duration (ms). Default value: 20ms. A timeout of zero can be used to block indefinitely.
func (*UDPClient) WriteBits ¶
WriteBits Writes bits to the PLC data area Example:
WriteBits(A, 100, 0, []bool{true,true}) will set A100=256 [00 03]
WriteBits(A, 100, 0, []bool{true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true}) will set A100=65535,A101=1 [FF FF 00 01]
func (*UDPClient) WriteBytes ¶
WriteBytes Writes bytes array to the PLC data area Example:
WriteBytes(A, 100, []byte{0x01}) will set A100=256 [01 00]
WriteBytes(A, 100, []byte{0x01,0x02}) will set A100=256+2 [01 01]
WriteBytes(A, 100, []byte{0x01,0x02,0x01}) will set A100=256+2, A101=256 [01 01 01 00]
Warning:
if len(b) is not even, I append 0 to the end of b, cause low byte of last memory will be set to 0
A200=1(0x00 0x01), call WriteBytes(A, 100, []byte{0x01}), A200 will be 256(0x01,0x00)
func (*UDPClient) WriteString ¶
WriteString Writes a string to the PLC data area Example:
WriteString(A, 100, "12") will set A100=[0x31,0x32] WriteString(A, 100, "1") will set A100=[0x31,0x00]
Warning:
same as WriteBytes, if len([]byte(s)) is not even, I append 0 to the end of b, cause low byte of last memory will be set to 0
type UDPServer ¶
type UDPServer struct {
// contains filtered or unexported fields
}
UDPServer Omron FINS server (PLC emulator) it is just for test, only DM area is supported. don't use in production fins server is PLC in normal, not our go programs
func NewUDPServerSimulator ¶
func NewUDPServerSimulator(plcAddr UDPAddress) (*UDPServer, error)
func (*UDPServer) SetReadPacketErrorLogger ¶
func (c *UDPServer) SetReadPacketErrorLogger(l Logger)
SetReadPacketErrorLogger read packet run background, we need a Logger to print error Default print error to stdout
func (*UDPServer) SetShowPacket ¶
func (c *UDPServer) SetShowPacket(show bool)