Commit Graph

35 Commits

Author SHA1 Message Date
Charl Wentzel
3626909786 Important Update:
- Added SendEnable (vir RTS pin) for TTL/RS485 converter
- Bug fix: Check for Handle->InTimeout before force output
2019-03-04 16:42:29 +02:00
Charl Wentzel
3e40f7a86d Important Update:
- Implement Handle Address renaming:
- Restructure JSON config, with address list and rename list
- SelectableCore:
  - Add method GetHandleAddress() - lookup renamed handle
  - Add init values to all struct and classes declarations
- Replace malloc()/strcpy() sequences with strdup()
2019-01-08 08:35:21 +02:00
Charl Wentzel
2ff8f556aa Important Update:
- Add "Custom" handle type to allow derived classes, e.g. BLEinterface
2018-12-09 11:13:54 +02:00
Charl Wentzel
a972fb9101 Major Update:
- Implement consistent Function addition to application
  - Use TYPE_XXX constants to declare function type
  - Use NewXXXX() methods to call constructor correctly
  - Add FunctionType list (with constructor) to Application
  - Create Function by comparison to FunctionType list
- Simplify LoadConfig() and Init() methods for functions
  - Combine methods into Init() method
  - Pass relevant data member to Init() method
  - Remove all CDataMember references on functions
- ApplicationCore:
  - Split ReadParam() method from LoadConfig() method
  - Split main configuration into separate files:
    - config/ - main config file, general application settings
    - definition/ - application definition, e.g. function blocks
  - Definition and Address List files specified in config file
  - Load address file in address/ branch
  - Made DataTree & JSONparser private
  - Made Config, Definition & Address branches public
  - Removed unnecessary branch references
  - Improved event logging
- DataTreeCore:
  - Allow GetChFirstChild & GetChElement to create parent branches
    with correct type, ie. Object/Array
  - Remove unnecessary Create param from GetXxx functions
  - Bug fix: Print empty objects/arrays correct, ie. empty brackets
  - Bug fix: Adding element at specific index
  - Bug fix: Error when get/create string value with "null"
- FunctionCore:
  - Type param now set as constant via constructor
  - Create empty Handles & Channels objects if none in Config
- SelectableCore:
  - Add Queue length parameter to handles for UNIX and TCP sockets
- DeviceCore:
  - Bug fix: missing Process() method
2018-11-24 13:35:23 +02:00
Charl Wentzel
7434334280 Major Update:
- FunctionCore, SelectCore, SelectableCore, DeviceCore, FileCore:
  - Update Logs to show [ProcessName]/[FunctionName]
- SelectableCore:
  - Update ConnectTypeName array (more readable)
  - Return THandle on all OpenXxxx() methods
  - Do not remove select handle for UDPremoteClient (same handle as server)
  - Add correct Handle when adding RemoteClient to Selector
2018-11-22 11:29:55 +02:00
Charl Wentzel
278198171d Important Update:
- SelectableCore:
  - Finish UDP implementation
    - Change UDPsock to UDPserver/client/remote
    - Add OpenUDPserver/client/remote methods
    - Add ReadFrom/WriteToUDP() methods (cannot write to FD)
    - ReadFrom/WriteToFD():
      - return negative bytes on error
      - small delay between consecutive reads/writes
  - Set address correctly on resolve (for UDP or TCP)
  - Improve ReadFrom/WriteToFD() methods (improved timing & error)
  - Improve error reporting on Input/OutputHandle() methods
- CharBufferCore:
  - Standardise ReadFrom/WriteToFD() method
  - Bug fix: Peek/PeekCopy error if Data param not passed
- FileCore
  - Standardise ReadFrom/WriteToFD() method
2018-11-19 19:52:39 +02:00
Charl Wentzel
1e74b9cd60 Important Update:
- SelectableCore:
  - Bug fix: StateCallBack array to small
  - Implemented and tested UNIX sockets
  - Started implementation of UDP sockets
  - Add "TCP" to TCP socket related methods and types
2018-11-18 18:29:20 +02:00
Charl Wentzel
d18e046e57 Important Update:
- SelectableCore:
  - Bug fix: correct ConnectTypeNames
  - Pass handle reference to Select when adding file discriptor.
  - Rename Select vars Handle -> SelectHandle
  - Show type and name of handle on Select logs
2018-11-04 17:31:12 +02:00
Charl Wentzel
4ec1dc6cd7 Important Update:
- Add Resolve Delay, allow time delay before resolving address
  Allow completion of other actions before blocking all to getaddr()
- Remove Handle->KeepAlive, assume always true
2017-12-10 21:39:55 +02:00
Charl Wentzel
7f39f8b985 Important update:
- SelectableCore:
  - Rename methods: SetSerialPortConfig() -> WriteSerialConfig(),
      GetSerialPortConfig() -> ReadSerialConfig(),
      InputHandle() -> OutputHandle(),
      ProcessBuffer() -> ProcessInputBuffer()
      SetPortHandle(config)() -> SetSerialHandle(Config)()
  - Rename serial port identification: "Port" -> "SerialPort"
    - Update logs accordingly
  - Add LinePrinter Port
    - Add to LoadConfig()
    - Add SetLinePrinterHandle() & OpenLinePrinterPort() methods
    - Add handling for open/read/write/close events
  - Add CloseDelay for AutoManage (non-persistent) ports
    - Rename handle timer: ReopenStart -> LastAction
    - Reset timer on all open/read/write/close events
    - Check for Close timeout in Process() and close port
    - Remove CloseChildren parameter on Close() method
    - Add QuickReopen parameter to Close() method
- SelectCore:
  - Overwrite existing handle - not yet removed
  - Handle In/Out baudrate on serial port separately
2017-12-06 08:43:25 +02:00
Charl Wentzel
3eaf0853fb Important Update:
- SelectableCore:
  - Move Serial port config params to Port/SerialConfig
  - Only configure serial port if config setting provided in JSON file
  - Add SerialConfig param to THandle struct, set when serial config given
  - Rename method: ConfigureSerialPort() -> SetSerialPortConfig()
  - New method: GetSerialPortConfig() read serial port config into Handle
  - Split method SetPortHandle():
    - SetPortHandle() - only set port type and address
    - SetPortHandleSerial() - only set serial port parameters
2017-12-01 10:56:48 +02:00
Charl Wentzel
92ce01a3b7 Important Update:
- JSONparseCore:
  - Bug fix: Incorrectly terminated PrintString on null
- SelectableCore:
  - Add BaudRate, DataBits, Parity, StopBits, FlowCtrl, DataWait to THandle
  - Include Serial Port setup in SetPortHandle()
  - Read Serial Port config in LoadConfigData()
  - Rename SetSerialConfig() -> ConfigureSerialPort()
  - Configure Serial Port immediately after opening port
2017-11-29 11:30:05 +02:00
Charl Wentzel
89123fa4af Important Update:
- SelectableCore:
  - Split SetBuffers() into SetInBuffer() and SetOutBuffer()
  - Rename SerialConfig() -> SetSerialConfig()
  - Add serial port configuration (eg. baudrate) to ConfigData
  - Read only no of bytes reported by FIONREAD
- DataTree:
  - Bug fix: Create Int/Float/Bool params if requested
2017-11-28 18:35:05 +02:00
Charl Wentzel
9f7e1b486e Important Update:
- SelectableCore:
  - Split handling of Handle from Input() to InputHandle() method
  - Allow multiple handles to be connected to single Channel
  - Update logs to report Handle, not Channel name
- TimingCore:
  - Convert all functions to inline functions in header (remove .cpp file)
  - Add new function TimeLeft()
- WatchdogCore:
  - Bug fix: No watchdog channel, use InputHandle() method not Input()
  - Bug fix: ping ignored, use To:"watchdog" in ping command
2017-11-21 10:15:26 +02:00
Charl Wentzel
7ef3d71af9 Important Updates:
- FunctionCore:
  - Output() returns largest no of bytes written to linked input
- SelectableCore:
  - Auto-manage:
    - Add AutoManage param -> Persistent
    - Will automatic open port if written to when Auto-Manage enabled
    - Will keep port open (re-open if closed) if Persistent = true
  - DNS resolve:
    - Set AddressFailed if port could not open/bind
    - Only use next resolved address if current address failed
2017-11-18 17:06:32 +02:00
Charl Wentzel
2f81d1fbbe Important Update:
- Library Clean up:
  - Removed all unused C/C++ libraries from source
  - First C/C++ libraries then redA libraries
- Library changes:
  - renamed BufferCore -> CharBufferCore
  - added ItemBufferCore
- CharBufferCore:
  - Derive RollingBuffer & ShiftBuffer from common class CharBuffer
  - CharBuffer is mostly a virtual class (interface)
2017-07-22 17:46:05 +02:00
Charl Wentzel
aaf3c59727 Important Updates:
- DataTreeCore:
  - Allow types float, int & bool to be read as strings with GetStr()
- LogCore:
  - Add comments to Logging parameters
- WatchDogCore:
  - Call CSelectableCore::Process() in Process() to manage connect
- SelectableCore:
  - Allow SetSocketHandle() to be called if Handle already set as socket
  - added strlcase() method to convert string to lower case
  - Update Handle structure:
    - renamed Address -> HostName
    - renamed PortNo -> PortName
    - added AddressList for all resolved addresses
    - added AddressInfo for active address
  - Add ResolveAddress() method
    - Domain name and protocol port resolving with GetAddrInfo()
  - JSON updated:
    - domain name can be provided instead of IP address
    - protocol can be specified instead of Port No, e.g. "HTTP" / "SSH"
  - Resolve address before connect, or use next resolved address
2017-07-22 09:40:17 +02:00
Charl Wentzel
c90cb7b0f4 Minor updates:
- FunctionCore:
  - Do not auto create empty channel list
- SelectCore:
  - Rename method: SetDebugLevel() -> LogLevel()
- SelectableCore:
  - Do not auto create empty handles list
2017-07-16 23:30:09 +02:00
Charl Wentzel
434377f122 Major Update:
- Implement new ApplicationCore:
  - Manage Tools: Log, DataTree, JSONparser & Selector
  - Load configuration, Manage FunctionBlocks
- FunctionCore & dirived classes, SignalCore:
  - affects: SelectableCore, DeviceCore, FileCore, WatchdogCore
  - Do not pass Log()
  - Define and pass Type
  - Update/reduce included headers
  - Use ProcessName and Application global vars
  - Get Log, DataTree from Application
  - Use virtual Init() function to set must have Channels/Handles
- DataTreeCore:
  - Bug fix: Check if child members exist and destroy in SetValuePtr()
  - Add method GetFirstChild with BaseMember & Path
  - Bug fix: do not use RootMember if no Parent in GetChildxxx() methods
- SignalCore, SelectCore:
  - Use Application->Log()
- FunctionCore:
  - Add itself to Application (function list)
  - Add parameter: LinkConfigMember, Type
  - Use virtual LoadConfigData() to configure from DataTree
  - Rename methods: LoadConfig() -> InitConfig(),
      InitLogging() -> SetLogParam(), SetDebugLevel() -> SetLogLevel()
  - Add method: GetType(), LoadChannelLinkData(), InitChannelLinks()
  - Modify LinkIn/OutputChannel() to use name for InFunction, not pointer
- SelectableCore & Dirived classes:
  - Affects DeviceCore & WatchdogClient
  - Rename parameter: Select -> Selector, BaseMember -> ConfigMember
  - Get Selector from Application->Selector
  - Change Handles JSON structure from Array to Key:Value pairs
  - Bug fix: check if Selector exist during Input()
  - Bug fix: do not set PortNo if not exist
2017-07-16 20:29:01 +02:00
Charl Wentzel
3f86de71b1 Major update:
- DataTreeCore:
  - Bug fix: GetMember() error if member not found
- FunctionCore: (affected: SelectableCore, FileCore, WatchdogCore)
  - Made destructor virual
  - Standardize method parameter naming, e.g. pName, pLog
  - Renamed parameters: DebugLevel -> LogLevel, OutputDisplay -> LogOutput
  - Reinstated parameter BaseMember
  - Removed logging parameters from constructor
  - Created method InitLoggging() (shows "Function Created" message)
  - Split LoadConfig() method into parts:
    - Implemented public LoadConfig() methods
    - Implemented LoadConfigData() method, load parameters from DataTree
- WatchdogCore:
  - Derive from CSelectableCore instead of CFunctionCore
  - Rename parameter: PingTimeout -> PingInterval
  - Replace Ping Channel with Handle only
  - Add method SetInterval()
  - Send command direct to handle with (channel) Input()
- SelectableCore:
  - Rename parameters: Auto -> AutoManage, ReopenTimeout -> ReopenDelay
  - Implemented own virtual LoadConfigData() method
- DeviceCore:
  - Made all logging conditional: if (Log) Log->Message(...)
- SelectCore:
  - Renamed parameters: DebugLevel -> LogLevel
2017-07-11 06:20:14 +02:00
Charl Wentzel
b7ed169730 Major Update & Bug fixes:
- FileCore:
  - Replace dlNone -> dlLow
  - Remove temporary code used by CBaslerCamera
- Function Core:
  - Add method SetDebugLevel()
  - Remove global parameter BaseMember;
- JSONparse:
  - Print Bool parameters as true/false, not 1/0
- SelectCore:
  - Add method SetDebugLevel()
- SignalCore:
  - Replace dlNone -> dlLow
2017-07-09 16:31:47 +02:00
Charl Wentzel
748b62d235 Important Update:
- SelectableCore:
  - Made GetType() & GetState() public methods
  - Update logs in Input()
- FunctionCore:
  - Add Input/OutputEnabled parameters with Get/Set methods.
  - Update logging in Input() and Output()
  - Check if input/output enabled in Input() and Output()
2017-07-05 10:59:24 +02:00
Charl Wentzel
b5763d7f50 Major Update: (compiling but untested)
- Replace CBuffer with CRollingBuffer and CShiftBuffer
  ShiftBuffer is faster and simpler and always zero terminates
- Updated SelectableCore to use RollingBuffer
- Add Overwrite parameter to Push() and ReadFromFD() methods
- Add PeakDirect() method for fast direct access to buffer
2017-03-22 03:43:29 +02:00
Charl Wentzel
92db4da7de Importnant update:
- Add callback functions for change in socket states
2017-02-16 03:12:18 +02:00
Charl Wentzel
c2acb4b77d Minor updates:
- CSelectableCore:
  - Allow ForkPipeHandle to change ExecPath
  - Remove parent/child process test comments
  - Move FD operations methods from private -> public
2016-10-24 17:53:50 +02:00
Charl Wentzel
7564e6a288 Major update:
- Rename Function LocalIO -> Channel (Parameters & Methods)
2016-08-23 13:19:43 +02:00
Charl Wentzel
5ea05d119e Major update:
- Logging
  - Created LogCore Class
  - Updated LogCore to use file descriptors instead of stdout
  - Add Log object reference to constructors for:
    FunctionCore, SelectCore
  - Use extern Log() object in SignalCore
- SelectableCore
  - Added new connection type: ForkedPipe
    Create pipe, fork process, connect pipe out to child stdin, exec
2016-08-22 12:14:53 +02:00
Charl Wentzel
eaace97ec9 Minor Update:
- BufferCore:
  - Method WriteToFD should ignore EAGAIN
- LogCore:
  - Add OUT_COUNT output bit (show total output bytes)
- SelectableCore:
  - Add Force param on WriteToFD, ignore EAGAIN if !Force
2016-07-27 13:42:50 +02:00
Charl Wentzel
1a9f825b25 Major Update:
- Minor fix: Set correct names in comments at top of file
- New FileCore Class:
  - Writing data to output file
- BufferCore:
  - Check for "EAGAIN" on write and retry write
- FunctionCore:
  - Add new Output method that references LocalIO directly
- SelectableCore:
  - New method SetAutomanage to specify auto re-open parameters
  - Re-open timer implemented to slow re-open events
  - Only call ProcessBuffer() if data received on socket
  - Force processing input data when no input marker set
  - Use new Output method to simplify code
  - Bug fix: Read correctly from buffer on multiple reads/writes on FD
  - Check for "EAGAIN" on write to FD and retry write
2016-07-20 09:37:25 +02:00
Charl Wentzel
b418fa73e0 Important Update:
- LogCore:
  - Removed global DebugLevel var, now passed as parameter
  - Implemented binary output values
- FunctionCore, SelectCore and SelectableCore:
  - internal DebugLevel param implemented
  - new internal DisplayOutput param (Normal/Hex/Bin)
- BufferCore:
  - Bug fix: allow for empty search string/marker
2016-06-09 06:53:09 +02:00
Charl Wentzel
b4073a166a Major Update:
- Updated all Logged messages, standardised DebugLevel:
  - dlNone   - Show startup and stop
  - dlLow    - Show creation/destruction of Function Blocks and Local IO
  - dlMedium - Show connection events, eg. open/close
  - dlHigh   - Show data flow events
-LogCore:
  - LogMessage and ShowOutput uses va_list
    only run printf if DebugLevel correct
  - Remove global LogStr[] variable
- SelectableCore:
  - Implemented Auto-management of handles
    auto open on startup/fail/close
  - Changed simple Open/Close/Read/Write methods to inline
  - Do not set Select Write trigger for server socket
  - Memory leak, setting address twice on RemoteClient
  - Bug fix, only send handle out data if DebugLevel = dlHigh
  - Bug fix, do not Read/ProcessBuffer if no InputBuffer
2016-05-27 13:32:54 +02:00
Charl Wentzel
c01c8f5e9b Major Update:
- Implemented global var DebugLevel
- Update LogCore to check DebugLevel
- Added many log messages and standadised all log messages
- Further improved validation checks on all methods
- Updated SelectCore, only remove SelectHandle from list during Test()
- Close Handles in SelectableCore destructor
Bug fixes:
- Non-blocking Client Socket Connection now working correctly
- Remove FD from Select lists at the correct time
2016-05-26 15:03:13 +02:00
Charl Wentzel
9ace97c1a3 Major update:
- General bug fixes
- Implement search for multi-character marker search in BufferCore
  Replaced FindChar() method with FindStr() method
- Implemented LocalIO and LinkedIO in FunctionCore
- Connect LocalIO with FD in SelectableCore
- Implement Write buffer with Write Select in SelectableCore
- Improve validation checks in SelectableCore
- Use Handle ptr instead of Handle Names for Config methods
2016-05-25 14:17:40 +02:00
Charl Wentzel
e83c09ecb6 Important Update:
- Converted Select functions into new class CSelectCore
- Move Read/Write code from main() to SelectableCore Read()/Write()
- Pass CSelectCore object to CSelectableCore on create
- Updated SelectCore Read/Write lists directly from SelectableCore
- SelectCore->Test() checks all FDs directly and call Read/Write functions
- Improved checking/validating for methods in SelectableCore
2016-05-24 15:02:51 +02:00
Charl Wentzel
dcfbd85efa Major Update:
- Merged SelectCore and PortCore into new SelectableCore
  Single well integrated Class
- Rename SelectCore.h to SelectableCore.h
- Create new TFileHandle structure for Ports/Sockets
- Moved buffer and Input Timeout from FunctionCore to TFileHandle
- Moved Read, Write and ProcessBuffer from FunctionCore to TFileHandle
Bug Fixes:
- malloc correct size for names
- Calculate MaxFD correctly when closing FDs
2016-05-23 14:35:15 +02:00