Commit Graph

151 Commits

Author SHA1 Message Date
Charl Wentzel
66fc4bc123 Important Update:
- Bug fix: incorrect memory allocation in SetValue()
- Implement conversion of escaped chars during parsing
- Implement escaping chars during printing
2017-04-03 21:48:29 +02:00
Charl Wentzel
2e2ba113f1 Major Update:
- Update printing: Do not use '\n' if indent = 0
- Implement refilling of buffer (from fd) while parsing
  - No longer use LineMark, but keep track of char position with CharNo
  - Use Mark to reference point for shifting buffer on refill
- SkipWhiteSpace no longer inline method
  - Refill buffer if required, change Mark & CharNo on line break
- CreateBuffer(), RefillBuffer() & FreeBuffer() now public methods
- Make Loading and Saving more flexible:
  - Refactor from LoadFromFile():
    ReadFromFile(), ReadFromHandle(), ReadFromBuffer()
  - Refactor from SaveToFile() & PrintToScreen:
    WriteToFile(), WriteToScreen, WriteToHandle()
2017-04-02 19:44:44 +02:00
Charl Wentzel
8f39adb0f3 Important update:
- Buffer:
  - fix undefined value: zero terminate buffer when loading from FD
- DataTree:
  - fix memory leak: destroy temporary search path
  - improve delete(): delete all children for member if no path given
  - bug fix: initiate object with 0 length (not -1)
- JSONparse:
  - Remove level parameter
  - Add path to load/save/print methods (print only portion of tree)
  - fix memory leak: destroy temporary object name
2017-03-29 21:27:28 +02:00
Charl Wentzel
5691b22df9 Minor Update:
- Pass printf Mask for Int/Float values on Get/Set methods
  - On GetValue use mask for default value
- Add SetArray() method
- Bug fix: Incorrect malloc size in SetValue()
- Bug fix: Len not calculated if -1 passed to SetValue()
- Set default value for Len = -1 on SetValue() methods
- Don't pass Len to SetValue() unless required
2017-03-27 04:29:11 +02:00
Charl Wentzel
a22f60b152 Major Update:
- Bug fix: BufferCore - set correct auto buffer size
- Change Get/Set methods to use BaseReference and full path instead of
    ParentPath and MemberName
- Add Create param to all Get methods (create if not found)
- Implement arrays & parsing of arrays
- Set CJSONparse as friend class to DataTree (access protected methods)
- Print JSON to screen
2017-03-26 22:26:52 +02:00
Charl Wentzel
b823bd7ea7 Important Update: (incomplete)
- Split CConfigCore into two classes:
  - DataTreeCore.h - Tree data structure and access
  - JSONparseCore.h - JSON parsing functionality
- Renamed TConfigParam struct to TDataMember
- Renamed most of CDataTreeCore methods
2017-03-23 20:53:32 +02:00
Charl Wentzel
ad4d8e8b5f Important update: (untested)
- Switch from FILE pointers to file descriptors (e.g. fopen() -> open())
- Replace internal buffer with CShiftBuffer
2017-03-23 13:21:21 +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
bb07ef63bf Important Update: (ConfigCore)
- Implemented full support for multi-layer objects
- Implemented RootObject for all other elements
- Added method CreateParam()
- Converted GetParam methods from inline to normal methods
- Added GetParent method
- Use Object->Len to count no of child objects
2017-03-18 23:03:51 +02:00
Charl Wentzel
508cf0fb0d Important Update: (incomplete)
- Implemented JSON type NULL
- Implement dynamic buffer
- Split parsing int separate re-usable methods
- Implement basic parsing of an object
- Add GetError() method
- Add SkipWhiteSpace as inline method
- Make parsing variable private attributes
- Improve checking when getting parameters
2017-03-15 04:29:01 +02:00
Charl Wentzel
9b180c77f5 Important Update:
- Added new Class: ConfigCore (Working but incomplete)
  - Provides basic parameter listing (bool, int, float, string)
  - Read/writes parameters from/to file
  - Support JSON format for key-value pair primitive and strings values
  - Support for objects and arrays to follow
2017-03-08 04:05:26 +02:00
Charl Wentzel
f57b340be6 Merge branch 'master' of /home/development/source/core/redAcore into BaslerCamera 2017-03-04 22:08:56 +02:00
Charl Wentzel
9c338715db Merge branch 'master' into JoaneControl 2017-03-04 21:51:42 +02:00
Charl Wentzel
e50ef57b47 gMerge branch 'JoaneTelemetry' 2017-03-04 21:44:53 +02:00
Charl Wentzel
ae95602f64 Important update:
- Bug fix: make DateTimeCore functions linkable by using it in CLogCore
- CLogCore:
  - Rename FileOutput -> OutputFile
  - Add DateTimeStr to Output if FileNo > 3
2017-03-04 21:44:39 +02:00
Charl Wentzel
e35ba3f024 Merge branch 'JoaneTelemetry' 2017-03-03 18:20:25 +02:00
Charl Wentzel
02b43fe6b8 Important update:
- Add new DateTimeCore file
- Provides functions to get/set system date
- Create Date, Time and Date/Time string with custom separators
2017-03-03 18:00:44 +02:00
Charl Wentzel
2d9faa7fa6 Important Update:
- Add GetValue/SetValue commands for Device command interface
- Bug fix: use case compare on searches
2017-03-02 12:31:50 +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
d4ee138da8 Update in progress:
- Started work on Set/Get commands for DeviceCore
2017-02-16 03:02:18 +02:00
Charl Wentzel
6d810e33ba Merge branch 'JoaneControl'
- additions for pipe control
- correction to display signed parameters correctly
2017-02-08 08:45:59 +02:00
Charl Wentzel
5c2d7d4b51 Bug fix:
- Display signed parameters correctly
2017-02-08 08:44:30 +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
47577e9f4c Major Updated:
- Added new CDeviceCore Class
  - Methods and structures moved from CModbusInterface
  - Keep track of Devices and DeviceParameters
  - Provides methods & parameters related to polling process
  - Provides parameter events
2016-09-07 08:49:58 +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
ac34066f30 Important Update: (Massive CPU usage improvement)
- Bug fix: Select timeout not constant, reduces to zero
- Only scan FDs if Select event occured
2016-06-02 12:38:47 +02:00
Charl Wentzel
630583bbc6 Minor Update:
- BufferCore: Set BufSize as class constant
- TimingCore: Add new function Timeout()
2016-06-02 09:36:08 +02:00
Charl Wentzel
59facdf1bd Important Update:
- Ingore SIGPIPE event, ie. writing to socket after it closed
2016-06-01 06:58:48 +02:00
Charl Wentzel
1aa0d98b35 Important Update:
- Add bidirectional flag for AddInput/AddOutput methods on FunctionCore
2016-05-31 07:24:51 +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
Charl Wentzel
0d1c46ac53 Major update:
- Converted CSocketCore to Class/Object
- Implemented CFunctionCore as base class for CPortCore and CSocketCore
- Moved common functions to CFunctionCore and renamed
  eg. Maintain() -> Process()
- Pass Objects directly to each other as OutputFunction
- New Input() method allows data transfer between objects
2016-05-19 15:10:55 +02:00
Charl Wentzel
e222d51997 Important Update:
- Implement Terminate counter
  Exit immediately on multiple terminate signals
- Move global var Terminate to SignalCore
2016-05-19 09:47:32 +02:00
Charl Wentzel
5c7eb956a7 Bug fixes:
- Implement changes from CoreBuffer
- Do not update BufLen in WriteToFD()
2016-05-19 09:46:18 +02:00
Charl Wentzel
839c8a1432 Important Update:
- Improve parameter checking before function execution
- Rename functions:
  Get->Peek, ReadFD->ReadFromFD, WriteFD->WriteToFD
- Add StartPos param to Peek() & FindChar()
- Add ClearChar param for GetChar()
- Add default values for Position and Lengths
  Get, Set, Clear, Push, Peek, GetChar, FindChar
2016-05-19 07:44:28 +02:00
Charl Wentzel
c50766021a Important Update:
- Still testing
- Separate Rolling Buffer from PortCore to BufferCore
- Implement BufferCore in PortCore
- Add additional Rolling Buffer functions for future
2016-05-18 15:09:02 +02:00
Charl Wentzel
f987ea2224 Important Update:
- Added SignalCore for handling system signals
- Implemented LogMessages (only output to stdout, later to logfile)
- Updated #defines for all header files
2016-05-17 12:24:51 +02:00
Charl Wentzel
eb0ab67499 Minor Update:
- Complete LogCore functions
- Implement ShowOutput() in Port and Socket functions
2016-05-17 11:23:57 +02:00
Charl Wentzel
d7facce4de Major update:
- Convert PortCore functions into Class
Bug fixes:
  - Correctly handle socket close event (return false on read)
  - Only write to port/socket if valid file handle
2016-05-17 07:44:08 +02:00