Commit Graph

54 Commits

Author SHA1 Message Date
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
c5da842ac1 Major Update:
- FunctionCore:
  - Add OutputFormat param on Output() method - override output format
- SelectableCore:
  - Update Log output formats (process/functionblock)
- DeviceCore:
  - Updated device data format (different byte sequences)
  - Added ID & Address fields to TDevice struct
  - Add search methods for ID & Address
  - Update AddDevice() method to check for duplicate ID & address
  - Handle Invalid reply different from reply timeout
  - Add methods ValidReplyReceived() for standardise operation
  - Bug fix: DeviceTypes added as to Device List!
  - Bug fix: Check if Device/DeviceType created before adding params
  - Added correct handling of new Device Data types (LH & HL)
  - Updated log messages
2018-12-16 00:42:43 +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
e3e5aa5258 Important Update:
- Bug fix: Handle not updated in SelectCore if SelectHandle re-used
2018-11-21 14:53:16 +02:00
Charl Wentzel
6263c0f508 Important update:
- DataTreeCore:
  - Renamed Get/SetMemXxx() methods to Get/SetChXxx()
  - Renamed GetMember() to GetChild()
  - Updated: JSONparse, ApplicationCore, FunctionCore, SelectableCore,
             and WatchdogCore
  - Remove unused PrevChild & Last vars in GetChild (GetMember)
- JSONparseCore:
  - Use return values from write() and PrintXxx() methods to report fail
- SelectableCore:
  - Fix possible uninitialised FlowCtrl & Parity value
- DateTimeCore:
  - Fix possible memory overrun in temp buffer
- EventBufferCore:
  - Fix possible uninitialised value error in AddEvent
2018-11-20 11:27:09 +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
2382ff4527 Important Update:
- DataTreeCore:
  - Rename all Get/SetChild...() methods to Get/SetMem...()
- Update all other objects with new methods
2018-11-17 20:02:47 +02:00
Charl Wentzel
f2a1ca950a Major Update:
- DataTreeCore:
  - Merge TDataMember and CDataTree into => CDataMember
  - Each node, incl root is now CDataMember object
  - Modified function to not require BaseMember (Object is basemember)
  - Split/duplicat most functions to require, or not require child path
  - Added isNull/Object/Array/Sting() etc methods
  - Many other methods removed or restructured
- Updated DataTree usage in: JSONparseCore,
  ApplicationCore, FunctionCore, SelectableCore, WatchdogCore
2018-11-17 19:10:59 +02:00
Charl Wentzel
d36bf3230b Minor fix:
- SelectableCore:
  - Bug fix: Incorrect handle passed to Select for RemoteClient
2018-11-04 19:02:01 +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
22a05ebd4e Important update:
- Bug fix: Set constant default address/port values for
    LinePrinter, TCPserver & TCPclient
2018-10-23 11:44:38 +01: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
75dec370f7 Minor Update:
- Fix log error on port close
2017-12-07 06:47:40 +02:00
Charl Wentzel
2c998ac7af Minor fix:
- Rename SOAP param: AutoMange/CloseDelay -> AutoManage/CloseTimeout
2017-12-06 11:10:11 +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
15e6d5a645 Important Update:
- SelectableCore:
  - Simplify Handle AutoManage logic
  - Bug fix: AutoManage fail to open (WaitingToOpen) if no data written
2017-11-29 12:51:29 +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
4ed36809b8 Important update:
- Detect serial port disconnect/close
2017-11-27 18:48:41 +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
c023cec697 Important update:
- Bug fix: Error when writing to closed socket
2017-11-20 15:32:21 +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
abba077ed0 Important Update:
- SelectableCore:
  - Skip IP address "0.0.0.0" when resolving localhost
2017-08-28 13:17:19 +02:00
Charl Wentzel
5f5e89e7cd Important update:
- EventBufferCore: (new)
  - Defines Events and related functions
  - Defines Event Buffer
- ItemBuffer:
  - Specify "Keep" parameter for Delete, to override CopyEntries
2017-08-21 20:51:10 +02:00
Charl Wentzel
2830b8dd6d Important Bug fixes:
- Remote Client connect not working properly
  - Set Client Port no on connect
  - Correctly handle create failure
  - Show error on fail
- Input() fail to transfer data if Handle & Channel not same name
  - Search for linked handles
2017-08-18 09:12:55 +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
c32875509d Minor updates:
- JSONparseCore:
  - Set File mode on create
- SelectableCore:
  - Check pipe() return value on create
  - Validate replacement of stdin with pipe
2017-07-17 22:51:30 +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
8933ec1ae6 Important Update:
- FunctionCore:
  - Fix Memory Leaks:
    - Recreate Name in LoadConfig()
    - Setting FirstChannel to NULL in LoadConfig()
  - Fix fault on empty Log/Output in LoadConfig()
  - Check if Log/Level exists in LoadConfig()
  - Do not auto-create all config parameters
- SelectableCore:
  - Fix Memory Leaks:
    - Setting FirstHandle to NULL in LoadConfig()
  - Do not auto-create all config parameters
  - Update logs to specifically refer to "TCP" server/client
2017-07-12 06:19:06 +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
4802452a7c Important Update:
- CLiteProtocol:
  - Set input string on methods to const char *
  - Simplify checking for verification
  - Ensure Length parameter can be left out on all methods
  - Add quick functions for structured commands: To, From, Command
- CLogCore:
  - Use only "\n", not "\r\n"
- SignalCore:
  - Use std::endl instead of "\r\n"
2017-07-08 22:23:50 +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
5b4e6822c7 Bug fixes:
- Fixed bugs on CRollingBuffer and CShiftBuffer
  - Remove "virtual" from methods declarations
  - Correct validation checks on methods
  - Use memmove to shift data in ShiftBuffer
  - Initialise buffer in RollingBuffer
  - FindStr() -> Return start position of match
  - Fix incorrect params passed to Peek()/PeekCopy() in Pop()/PopCopy()
  - Fix endless lopp in RollingBuffer::Push()
2017-03-22 07:52:58 +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
6fee4d0eac Important Update:
- BufferCore:
  - Added PeekCopy and PopCopy methods
- SelectableCore:
  - Add status checking of Handle on Read and Write
  - Reject input if Handle not open
- TimingCore:
  - Added method ClearStartTime
2016-07-06 15:17:10 +02:00
Charl Wentzel
1ced40260d Minor Update:
- Added Output on Function Output events
2016-06-15 12:03:15 +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
13b0a4736c Minor Update:
- Use Timeout function in SelectableCore
2016-06-02 13:44:30 +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