Phipli / SmartBox

Python Library for using the Economatics Smart Box with modern computers over serial
0 stars 0 forks source link

SmartBox Discovery DataApp #5

Open hickery opened 4 years ago

hickery commented 4 years ago

The SmartBox Discovery had an inbuilt DataApp, which could be controlled by the screen/keypad on the box.

When the DataApp was running, it responded with this protocol definition to download stored data etc.:


12.03.98

'>' denotes a byte sent from the host
'<' denotes a byte received from the box

rem_Engine = 1
    Read engine number
    > Required engine number
    < Engine number that will be used (currently minimum of 13)

rem_Quit = 2
    Quits DataApp

rem_Status = 4
    Read status
    < Status
        &01 to &0f - log
            &01 not logging
            &02 logging
        &11 to &1f - time
            &11 not timing
            &12 timing: waiting for stop
            &13 timing: waiting for user cont
            &14 timing: waiting for start
        &22 to &2f - ctrl
            &21 idle
            &22 running
            &23 paused
        &31 to &3f - sense
            &31 not logging
            &32 logging
            &33 averaging
        &80 - main screen
        &FF - startup screen

rem_CallJob = 5
    Calls OS JobCall
    > JobCall

rem_ReadStores = 6
    Read status of stores
    < Stores bit flags for Log (1 bit per store)
    < Stores bit flags for Time
    < Stores bit flags for Ctrl
    < Stores bit flags for Snse

rem_ReadStore = 7
    Read store data
    > Store number
    < Flag (if 0 then store doesn't exist)
    < [store data]

rem_WriteStore = 8
    Write store data
    > Store number
    > Length of store (LSB) - from byte 0
    > Length of store (MSB)
    < Flag
        0 = Ok
        1 = No room for store
    > [rest of store data if ok]

rem_DelStore = 9
    Delete store
    > Store number

rem_AppSleep = 18
    Make Data not generate host based events

rem_WriteAppOpts = 17
    Write general Data opts to CMOS
    > Opts
        b0 = Ctrl demo procedure disabled
        b1 = Printer does not need linefeed

rem_ReadAppOpts = 18
    Read general Data opts
    < Opts

rem_AppQuit = 19
    Quit to front menu

---

rem_LogReadOpts = 10
    Read Log options
    < Sample time in CS (LSB)
    < Sample time in CS
    < Sample time in CS (MSB)
    < Store size (LSB)
    < Store size (MSB)

rem_LogWriteOpts = 11
    Write Log options
    > Sample time in CS (LSB)
    > Sample time in CS
    > Sample time in CS (MSB)
    > Store size (LSB)
    > Store size (MSB)

rem_LogStart = 12
    Start Log
    < Flag
        0 = Ok, sampling started
        1 = No spare store (following byte isn't sent)
        2 = No room for store (following byte isn't sent)
    < Store number

rem_LogStatus = 13
    Read Log status
    < Status (as rem_Status)
    < Store number
    < Current position in store (LSB)
    < Current position in store (MSB)
    < Total store size (LSB)
    < Total store size (MSB)

rem_LogStop = 14
    Stop logging

---

rem_TimeStart = 20
    Start timing
    < Flag
        0 = Ok, sampling started
        1 = No spare store (following byte isn't sent)
    < Store number

rem_TimeStop = 21
    Stop timing

rem_TimeLap = 22
    Lap timing

rem_TimeCont = 23
    Cont timing

rem_TimeStatus = 24
    Read Time status
    < Status (as rem_Status)
    < Current log time (LSB)
    < Current log time
    < Current log time
    < Current log time (MSB)
    < Last sample (lap) time (LSB)
    < Last sample (lap) time
    < Last sample (lap) time
    < Last sample (lap) time (MSB)

rem_TimeReadOpts = 25
    Read Log options
    < Gate option
        0 = Keypad only
        1 = Start on 1 break, stop on 1 make
        2 = Start on 1 make, stop on 1 break
        3 = Start on 1 break, stop on 1 break
        4 = Start on 1 make, stop on 1 make
        5 = Start on 1 break, stop on 2 make
        6 = Start on 1 make, stop on 2 break
        7 = Start on 1 break, stop on 2 break
        8 = Start on 1 make, stop on 2 make
        9 = Start on 1 break, stop on 1 make, lap, start,
            stop on 2 break, lap, start, stop on 2 make

rem_TimeWriteOpts = 26
    Write Log options
    > Gate option

---

rem_CtrlStart = 30
    Start ctrl
    > Store number

rem_CtrlStop = 31
    Stop ctrl

rem_CtrlPause = 32
    Pause ctrl

rem_CtrlCont = 33
    Cont ctrl

rem_CtrlStep = 34
    Step ctrl

rem_CtrlStatus = 35
    Read Ctrl status
    < Status (as rem_Status)
    < Run status
        b0/b1 = Conditional
            0 = No conditional
            1 = True, execute until else
            2 = False, looking for else
            3 = Else found, looking for endif
        b2 = Stepping
    < Store being run

rem_CtrlRunningLine = 36
    Read running line
    < Status (as rem_Status)
    < Run status
    < Store being run
    < Offset into store of line being run (LSB)
    < Offset into store of line being run (MSB)

---

rem_SnseStart = 40
    Start sensing
    < Flag
        0 = Ok, sampling started
        1 = No spare store (following byte isn't sent)
    < Store number

rem_SnseStop = 41
    Stop sensing

rem_SnseNext = 42
    Log next sense

rem_SnseStatus = 43
    Read Snse status
    < Status (as rem_Status)
    < Store number
    < Current position in store (LSB)
    < Current position in store (MSB)

rem_SnseReadOpts = 44
    Read Log options
    < Average time in CS (LSB)
    < Average time in CS (MSB)

rem_SnseWriteOpts = 45
    Write Log options
    > Average time in CS (LSB)
    > Average time in CS (MSB)

---

host_CtrlStep = 30
    About to step

---

Sample time is a 24 bit number.

After starting logging use rem_Status or rem_LogStatus to check for when logging has ended (ie. a value other than 2 is returned).

Log stores are in the range 1 to 8
Time stores are in the range 17 to 24 (&11 TO &18)
Ctrl stores are in the range 33 to 40 (&21 TO &28)
Snse stores are in the range 49 to 56 (&31 TO &38)

The format of the Log store data is:

    Byte    Description

    0   Store number
    1   Length of store (LSB) - from byte 0
    2   Length of store (MSB)
    3   Sensor A
    4   Sensor B
    5   Sensor C
    6   Sensor D
    7   Number of records in store data (LSB)
    8   Number of records in store data (MSB)
    9   Sample time (LSB)
    10  Sample time
    11  Sample time (MSB)
    12  RTC seconds (BCD)
    13  RTC minutes (BCD)
    14  RTC hour (BCD)
    15  RTC date (BCD)
    16  RTC month (BCD)
    17  RTC day (1-7)
    18  RTC year (BCD)
    19  Store data
    [x] End of store data

The format of the Time store data is:

    Byte    Description

    0   Store number
    1   Length of store (LSB) - from byte 0
    2   Length of store (MSB)
    3   Sensor A
    4   Sensor B
    5   Sensor C
    6   Sensor D
    7   Number of records in store data (LSB)
    8   Number of records in store data (MSB)
    9   RTC seconds (BCD)
    10  RTC minutes (BCD)
    11  RTC hour (BCD)
    12  RTC date (BCD)
    13  RTC month (BCD)
    14  RTC day (1-7)
    15  RTC year (BCD)
    16  Store data (4 bytes in cs)
    [x] End of store data

The format of the Ctrl store data is:

    Byte    Description

    0   Store number
    1   Length of store (LSB) - from byte 0
    2   Length of store (MSB)
    3   Store data (CR terminated strings, terminated by NUL)
    [x] End of store data

The format of the Snse store data is:

    Byte    Description

    0   Store number
    1   Length of store (LSB) - from byte 0
    2   Length of store (MSB)
    3   Sensor A
    4   Sensor B
    5   Sensor C
    6   Sensor D
    7   Number of records in store data (LSB)
    8   Number of records in store data (MSB)
    9   RTC seconds (BCD)
    10  RTC minutes (BCD)
    11  RTC hour (BCD)
    12  RTC date (BCD)
    13  RTC month (BCD)
    14  RTC day (1-7)
    15  RTC year (BCD)
    16  Store data
    [x] End of store data
Phipli commented 4 years ago

Was the SB-01 / EV software much different to the standard SB-01 software? I have one on the way in the post. From an old advert, I can see that it was able to retain its program between power cycles, beyond that, I have seen very little about them. Even the guy selling it had just listed it as an SB-01.

hickery commented 4 years ago

Not really, the OS has support for the BBR (yours will no doubt come with Varta death), so it can do a soft reset rather than a full reset, and short support - it was deemed that schoolkids would be prone to sticking anything into anything and because of the extra voltage / current of the EV (which some took as Enhanced Version, but I referred to as Extra Voltage) it was wise that the box should detect this, shutoff outputs and indicate a user error.

You can tell the EV OS version by "b[br]s[short]", ie. 2.073bs, though it will run in any bob box and we probably did start shipping the one EPROM version in non-EV boxes as well.

hickery commented 4 years ago

I do have the RISC OS version of !SmartStart for retrieving DataApp data and drawing graphs etc, but only the source !

If someone gets a a Discovery and requests it I'll see about getting a dev system up again and creating an actual !RunImage.