Data collection core that utilises the nine ring buffer. Intended as the base of other data collection projects

Files at this revision

API Documentation at this revision

Comitter:
jont
Date:
Mon Jul 13 08:02:01 2015 +0000
Parent:
2:8587554a1f52
Commit message:
First pre-release without proper docs as the build system seems to be broken

Changed in this revision

nine_ring/nine_ring.cpp Show diff for this revision Revisions of this file
nine_ring/nine_ring.h Show diff for this revision Revisions of this file
ninelocks_logger_core/ninelocks_logger_core.h Show annotated file Show diff for this revision Revisions of this file
readme.txt Show annotated file Show diff for this revision Revisions of this file
record_ring/record_ring.cpp Show diff for this revision Revisions of this file
record_ring/record_ring.h Show diff for this revision Revisions of this file
diff -r 8587554a1f52 -r ba7863bdf478 nine_ring/nine_ring.cpp
--- a/nine_ring/nine_ring.cpp	Sat Jul 11 17:32:02 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-#include "mbed.h"
-#include "nine_ring.h"
-/*
-J.J.Trinder, based on original code for midi projects 199X
-updateded sometime to the MBED
-
-Yeh its atad klunky, it works and is useful to explain things to people...
-*/
-#define _PC
-NRing::NRing()
-{
-   ring_init();
-}
-
-
-
-/*======================================================================*/
-/* implementation of Ringbuffer                     */
-/*======================================================================*/
-void NRing::ring_init(void)
-{
-    inIndex = 0;
-    inCount = 0;
-}
-
-/*======================================================================*/
-/* RingWriteToBuffer                     */
-/*======================================================================*/
-//add critical section ie disable interrupts while fiddling with buffers
-int NRing::RingWriteToBuffer(long n)
-{
-   // printf("WriteInBuffer%d",inCount);
-__disable_irq();    // Disable Interrupts
- 
-// do something that can't be interrupted
-   opBuffer[inIndex] = n;
-    inCount++;
-    inIndex++;
-    if (inIndex >= buff_size)
-        inIndex = 0;
-   
- 
-__enable_irq();     // Enable Interrupts 
-  //printf("ZWriteInBuffer%d\n",inCount);       
-    return 0;
-}
-
-
-//todo fix this as we dont want to do this
-/*======================================================================*/
-/* return current count of stuff in buffer           */
-/*======================================================================*/
-int NRing::ring_count()
-{
-   // printf("InCount %d",inCount);
-    return (inCount);
-}
-
-
-//todo fix this as we dont want to do this
-/*======================================================================*/
-/* Output whats remaining....            */
-/*======================================================================*/
-long NRing::get_next()
-{
-   
-    long toSend;
-#ifdef _PC
-    printf("\nCall in %x out %x count %x",inIndex,outIndex, inCount);
-#endif
-    if (inCount == 0)
-        return -1;     /* nowt to send */
-    __disable_irq();    // Disable Interrupts    
-    toSend = opBuffer[outIndex];
-
-#ifdef _PC
-    printf(" <%i> ",toSend);
-#endif
- 
-    inCount--;
-    outIndex++;
-    if (outIndex >=buff_size)
-        outIndex = 0;
-    __enable_irq();     // Enable Interrupts       
-    return toSend;
-}
-
diff -r 8587554a1f52 -r ba7863bdf478 nine_ring/nine_ring.h
--- a/nine_ring/nine_ring.h	Sat Jul 11 17:32:02 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-#ifndef NL_RING
-#define NL_RING
-
-/*
-J.J.Trinder, based on original code for midi projects 199X
-updateded sometime to the MBED
-
-Yeh its atad klunky, it works and is useful to explain things to people...
-*/
-#define buff_size 120
-class NRing {
-public:
-        NRing();    
-        
-        void ring_init();
-        int ring_count();
-        long get_next();
-        int RingWriteToBuffer(long);        /* put byte in buffer       */ 
-        
- protected:          
-        volatile int inIndex; /* where to put next byte           */
-        volatile int inCount; /* how full is the buffer           */
-        volatile int outIndex;   /* for output to sio             */
-        
-
-  long opBuffer[buff_size];    /* our Ring out buffer  */
-}; 
-
-#endif
\ No newline at end of file
diff -r 8587554a1f52 -r ba7863bdf478 ninelocks_logger_core/ninelocks_logger_core.h
--- a/ninelocks_logger_core/ninelocks_logger_core.h	Sat Jul 11 17:32:02 2015 +0000
+++ b/ninelocks_logger_core/ninelocks_logger_core.h	Mon Jul 13 08:02:01 2015 +0000
@@ -4,20 +4,35 @@
 #include "record_ring.h"
 
 #define nl_name_length 100
+/**
+Data collection system that uses the ninelocks ring buffer and record ring buffer library as part of a data collection system
+This is based on very old early 1990s code from another project. Its been tweaked to allow use of the mbed
+
+This code expect you to derive your own data collection function inheritaed from this class and implement your own functions ofr
+
+
+*/
+
 class NineLoggerCore {
 public:
     NineLoggerCore();
     NineLoggerCore(Serial * pc);
-    void do_journal(long seconds, char entryType);
-    bool flush_buffered_journal_events();
     void setfilename(char* filename);
+    
+    //these are general 
     int get_overrun_count();
     int get_write_error_count();
     int get_max_fill(); //see how much of ring buffer got used at worse
+    // You should implement these in your own class, ie override them.
+    //I may eventuall y make these callbacks instead.
+    
+    void do_journal(long seconds, char entryType);
+    bool flush_buffered_journal_events();
+    
+    
   //  virtual bool write_error_log() { return true; }
   //  void flash(int n);
  
-  
 private:  
    
 protected:  
diff -r 8587554a1f52 -r ba7863bdf478 readme.txt
--- a/readme.txt	Sat Jul 11 17:32:02 2015 +0000
+++ b/readme.txt	Mon Jul 13 08:02:01 2015 +0000
@@ -3,7 +3,7 @@
 Dr J.J.Trinder 2015
 This is a simple data logger library, mostly written for my own use and as demo code to explain principles
 
-A lot of it is based on C I wrote  to do Ham radio reepeater control and control MIDI instruments.
+A lot of it is based on C I wrote  to do Ham radio repeater control and control MIDI instruments.
 
 
 */
\ No newline at end of file
diff -r 8587554a1f52 -r ba7863bdf478 record_ring/record_ring.cpp
--- a/record_ring/record_ring.cpp	Sat Jul 11 17:32:02 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-#include "mbed.h"
-#include "record_ring.h"
-/*
-J.J.Trinder, based on original code for midi projects 199X
-updateded sometime to the MBED
-Yeh its atad klunky, it works and is useful to explain things to people...
-*/
-
-JRecordRing::JRecordRing()
-{
-    int bufsize = buff_size;
-    buf = new log_record [bufsize+1];
-    // sp = ep = buf;
-    memset(buf,0,bufsize);
-}
-
-JRecordRing::~JRecordRing()
-{
-//not convinced this cleans up properly
-    delete [] buf;
-}
-/*======================================================================*/
-/* RingWriteToBuffer                     */
-/*======================================================================*/
-//add critical section ie disable interrupts while fiddling with buffers
-int JRecordRing::RingWriteToBuffer(log_record n)
-{
-    // printf("WriteInBuffer%d",inCount);
-    __disable_irq();    // Disable Interrupts
-
-// do something that can't be interrupted
-    opBuffer[inIndex].timestamp = n.timestamp;
-    opBuffer[inIndex].ad1 = n.ad1;
-    opBuffer[inIndex].ad2 = n.ad2;
-    opBuffer[inIndex].ad3 = n.ad3;
-    opBuffer[inIndex].ad4 = n.ad4;
-    opBuffer[inIndex].ad5 = n.ad5;
-    opBuffer[inIndex].ad6 = n.ad6;
-    opBuffer[inIndex].count = n.count;
-    opBuffer[inIndex].count2 = n.count2;
-    opBuffer[inIndex].record_type = n.record_type;
-    opBuffer[inIndex].temperature = n.temperature;
-    inCount++;
-    inIndex++;
-    if (inIndex >= buff_size)
-        inIndex = 0;
-    __enable_irq();     // Enable Interrupts
-    //printf("ZWriteInBuffer%d\n",inCount);
-    return 0;
-}
-
-
-/*======================================================================*/
-/* Output whats remaining....            */
-/*======================================================================*/
-long JRecordRing::get_next_record(log_record * lr)
-{
-
-    //  long toSend;
-#ifdef _PC
-    printf("\nCall in %x out %x count %x",inIndex,outIndex, inCount);
-#endif
-    if (inCount == 0)
-        return -1;     /* nowt to send */
-    __disable_irq();    // Disable Interrupts
-    //lr. = opBuffer[outIndex];
-    lr->timestamp = opBuffer[outIndex].timestamp;
-    lr->ad1 =     opBuffer[outIndex].ad1;
-    lr->ad2 =     opBuffer[outIndex].ad2;
-    lr->ad3 =     opBuffer[outIndex].ad3;
-    lr->ad4 =     opBuffer[outIndex].ad4;
-    lr->ad5 =     opBuffer[outIndex].ad5;
-    lr->ad6 =     opBuffer[outIndex].ad6;
-    lr->count =   opBuffer[outIndex].count;
-    lr->count2 =  opBuffer[outIndex].count2;
-    lr->temperature =  opBuffer[outIndex].temperature;
-    lr->record_type =  opBuffer[outIndex].record_type;
-
-#ifdef _PC
-    printf(" <%s> ",lr->count);
-#endif
-    inCount--;
-    outIndex++;
-    if (outIndex >=buff_size)
-        outIndex = 0;
-    __enable_irq();     // Enable Interrupts
-    return 0; //check what we should return as now record in the arg
-}
\ No newline at end of file
diff -r 8587554a1f52 -r ba7863bdf478 record_ring/record_ring.h
--- a/record_ring/record_ring.h	Sat Jul 11 17:32:02 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-#ifndef _RECORD_RING
-#define _RECORD_RING
-#include "nine_ring.h"
-/*
-J.J.Trinder, based on original code for midi projects 199X
-updateded sometime to the MBED
-
-Its a ring buffer for records of data
-Yeh its atad klunky, it works and is useful to explain things to people...
-*/
-
-/*======================================================================*/
-/* Data structures to be used                       */
-/*======================================================================*/
-
-/*
-At the moment an aribtry collection of mostly float values.
-
-If you want different, then fork the library and modify as you see fit.
-
-*/
-typedef struct
-{
-  //  long sampleID;
-    long timestamp; // time stamp
-    float ad1;
-    float ad2;
-    float ad3;
-    float ad4;
-    float ad5;
-    float ad6;
-    int count;
-    int count2;
-    float temperature;
-    char record_type; //J for journal E for event etc
-
-}log_record;
-
-class JRecordRing :  public  NRing {
-public:
-        JRecordRing();
-        ~JRecordRing();
-        int RingWriteToBuffer(log_record );
-        long get_next_record(log_record*);
-protected:
-log_record opBuffer[buff_size];    /* our Ring out buffer  */
-log_record * buf;
-}; 
-
-
-#endif