Re: FreeEMS Serial Protocol
Posted: Tue Jul 29, 2014 1:33 am
You mean interface as in API? What set of files and functions would you say compose the interface? Where can I get them?
TRUE DIY engine management discussion forum
http://forum.diyefi.org/
Code: Select all
numberOfChunks: 3,
logChunks: {
[0] = {
address: &CoreVars0,
size: sizeof(CoreVar)
},
[1] = {
address: &DerivedVars0,
size: sizeof(DerivedVar)
},
[2] = {
address: &KeyUserDebugs,
size: sizeof(KeyUserDebug)
}
},
Code: Select all
typedef struct {
/* Calculated and averaged from ADC0 readings */
unsigned short IAT; ///< Inlet Air Temperature : 0.0 - 655.35 (0.01 Kelvin (/100))
unsigned short CHT; ///< Coolant / Head Temperature : 0.0 - 655.35 (0.01 Kelvin (/100))
unsigned short TPS; ///< Throttle Position Sensor : 0.0 - 102.398438 (0.0015625 % (/640))
unsigned short EGO; ///< Exhaust Gas Oxygen : 0.0 - 1.99996948 (0.0000305175781 lambda (/32768))
unsigned short MAP; ///< Manifold Absolute Pressure : 0.0 - 655.35 (0.01 kPa (/100))
unsigned short AAP; ///< Atmospheric Absolute Pressure : 0.0 - 655.35 (0.01 kPa (/100))
unsigned short BRV; ///< Battery Reference Voltage : 0.0 - 65.535 (0.001 Volts (/1000))
unsigned short MAT; ///< Manifold Air Temperature : 0.0 - 655.35 (0.01 Kelvin (/100))
/* Calculated and averaged from ADC1 readings (Subject to change! http://issues.freeems.org/view.php?id=190) */
unsigned short EGO2; ///< Exhaust Gas Oxygen : 0.0 - 1.99996948 (0.0000305175781 lambda (/32768))
unsigned short IAP; ///< Intercooler Absolute Pressure : 0.0 - 655.35 (0.01 kPa (/100))
unsigned short MAF; ///< Mass Air Flow : 0.0 - 65535.0 (raw units from lookup)
/* Calculated from MAP and TPS history */
unsigned short DMAP; ///< Delta MAP kPa/second or similar
unsigned short DTPS; ///< Delta TPS %/second or similar
/* Calculated from engine position data */
unsigned short RPM; ///< Revolutions Per Minute (Calced) : 0.0 - 32767.5 (0.5 RPM (/2))
unsigned short DRPM; ///< Delta RPM (Calced) : 0.0 - 32767.5 (0.5 RPM/Second (/2))
unsigned short DDRPM; ///< Delta Delta RPM (Calced) : 0.0 - 32767.5 (0.5 RPM/Second^2 (/2))
} CoreVar;
Code: Select all
typedef struct {
/* */
unsigned short LoadMain; ///< Configurable unit of load, same scale as VE by default
unsigned short VEMain; ///< Divide by 512 to get 0 - 128%
unsigned short Lambda; ///< Divide by 32768 to get Lamda 0 - 2.0
// TODO remove these:
unsigned short AirFlow; ///< Top half of the equation - intermediate, take this out of derived vars into own special struct with other intermediates
unsigned short densityAndFuel; ///< Bottom half of the equation - ditto, or, just ditch. This is dev/debug code, really...
unsigned short BasePW; ///< Raw PW before corrections divide by PW_TICK_FACTOR for milli seconds
unsigned short ETE; ///< Engine Temperature Enrichment percentage correction divide by 327.68 for 0 - 200%
signed short TFCTotal; ///< Transient fuel correction PW (+/-) divide by PW_TICK_FACTOR for milli seconds
unsigned short EffectivePW; ///< Actual PW of fuel delivery, before per channel corrections, divide by PW_TICK_FACTOR for milli seconds
unsigned short IDT; ///< PW duration before fuel flow begins, before per channel corrections, divide by PW_TICK_FACTOR for milli seconds
unsigned short RefPW; ///< Reference electrical PW what each cylinder is based on, used for all general decisions, divide by PW_TICK_FACTOR for milli seconds
unsigned short Advance; ///< Ignition advance (scaled degrees / ANGLE_FACTOR = degrees)
unsigned short Dwell; ///< Dwell period, divide by PW_TICK_FACTOR for milli seconds
} DerivedVar;
Code: Select all
typedef struct {
// To be improved MAJORLY:
unsigned char tempClock; ///< Incremented once per log sent
unsigned char spareChar; ///< Unused at this time.
// All flags! Pair keeps things sane for hacky apps that think everything is 16 bit.
unsigned char coreStatusA; ///< Duplicated, migrate here, remove global var
unsigned char decoderFlags; ///< Various decoder state flags
unsigned short flaggableFlags; ///< Flags to go with our flaggables struct.
// counter flags once counter mechanism implemented
// These things should only exist once in memory, and should be grouped in a struct, perhaps this one
unsigned char currentEvent; ///< Which input event was last to come in
unsigned char syncLostWithThisID; ///< A unique identifier for the reason behind a loss of sync
unsigned char syncLostOnThisEvent; ///< Where in the input pattern it all went very badly wrong
unsigned char syncCaughtOnThisEvent; ///< Where in the input pattern that things started making sense
unsigned char syncResetCalls; ///< Sum of sync losses and state clears
unsigned char primaryTeethSeen; ///< Free running counters for number of input events, useful at lower RPM
unsigned char secondaryTeethSeen; ///< @copydoc primaryTeethSeen
// Likewise these too
unsigned char serialOverrunErrors; ///< Incremented when an overrun occurs due to high interrupt load, not a fault, just a fact of life at high RPM
unsigned char serialHardwareErrors; ///< Sum of noise, parity, and framing errors
unsigned char serialAndCommsCodeErrors; ///< Sum of checksum, escape mismatches, starts inside, and over/under length
unsigned short inputEventTimeTolerance; ///< Required to tune noise rejection over RPM TODO add to LT1 and MissingTeeth
// TODO move this up above with the other flags post OLV 0.0.3 release
unsigned short flaggableFlags2; ///< Flags to go with our flaggables2 struct.
// replace highest first to avoid hassles for offset based dave/mtx...
unsigned short zsp9; ///< Spare US variable
unsigned short zsp8; ///< Spare US variable
unsigned short zsp7; ///< Spare US variable
unsigned short zsp6; ///< Spare US variable
// TODO move these:
unsigned short blendAlphaNPercent; ///< TODO migrate to correct place once OLV/EMStudio are flexible...
unsigned short speedDensityAirFlow; ///< TODO migrate to correct place once OLV/EMStudio are flexible...
unsigned short alphaNAirFlow; ///< TODO migrate to correct place once OLV/EMStudio are flexible...
// Do we want these recorded at log assembly time, or at recording of ADC time, or at calculation of vars (core and/or deriv) or at enabling of scheduling, or all of the above?
unsigned short clockInMilliSeconds; ///< Migrate to start of all large datalogs once analysed
unsigned short clockIn8thsOfAMilli; ///< Migrate to start of all large datalogs once analysed
unsigned char ignitionCuts; ///< Up to 8 reasons to not schedule ignition
unsigned char injectionCuts; ///< Up to 8 reasons to not schedule injection
} KeyUserDebug;
As per a document I'm assuming Fred already sent you (If he did not, ask and I'll see if I can find it again), you figured outAA 01 01 91 00 62 B7 CB BA 0D 03 6B 41 80 04 47 04 69 01 37 B7 CB 00 0C 00 0D 00 06 00 00 00 00
00 00 00 00 00 00 04 47 38 00 80 00 01 32 84 54 00 91 53 33 00 00 00 BC 0E 36 0E F2 00 00 47 0C D6
00 00 00 00 D0 00 00 00 00 00 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 35 19 A8 CF 00 00 F3 CC
You got two things wrong there, 0x01 means the 0th bit is on, not 7th which is HAS_LENGTH This means that the two bytes after the payload (again, re the protocol document) 00 62 is the length. This means everything else except your checksum and stop byte is the packet itself.0xAA : Start of packet
0x01 : 7th bit is on. I know Bit 0 - Has Length, Bit 1 - Is Negative Acknowledgment, Bit 2 - Has Sequence. What are Bit 3, 4, 5,6 and 7?
0x0191 : Basic Datalog packet???
0x00 : Mode Stop