Thank you for such a speedy reply!
Since every byte is different and every bit field is different joining them all together as an array of (0-31) won't work. What I was working on but feel is the wrong direction was this definition of each byte here:
Code: Select all
Public Const Clock_f41 as UnsignedInteger = &H0200 '3 bytes
Public Const Date_f41 as UnsignedInteger = &H0203 '3 bytes
Public Const SampleRate_f41 as UnsignedInteger = &H0206 '2 bytes Integer
Public Const TempLowAlarm_f41 as UnsignedInteger = &H0208
Public Const TempHighAlarm_f41 as UnsignedInteger = &H0209
Public Const HumidityLowAlarm_f41 as UnsignedInteger = &H020A
Public Const HumidityHighAlarm_f41 as UnsignedInteger = &H020B
Public Const Temp_f41 as UnsignedInteger = &H020C '1.5 bytes
Public Const Humidity_f41 as UnsignedInteger = &H020E '1.5 bytes
Public Const TempAlarmControl_f41 as UnsignedInteger = &H0210
Public Const HumidAlarmControl_f41 as UnsignedInteger = &H0211
Public Const ClockControl_f41 as UnsignedInteger = &H0212
Public Const MissionControl_f41 as UnsignedInteger = &H0213
Public Const AlarmStatus_f41 as UnsignedInteger = &H0214
Public Const GeneralStatus_f41 as UnsignedInteger = &H0215
Public Const StartDelayLow_f41 as UnsignedInteger = &H0216 '3 bytes Long
'Public Const StartDelayHigh_f41 as UnsignedInteger = &H0218
Public Const MissionTimeStamp_f41 as UnsignedInteger = &H0219 '6 bytes time+date
Public Const MissionSamples_f41 as UnsignedInteger = &H0220 '3 bytes Long
Public Const DeviceSamples_f41 as UnsignedInteger = &H0223 '3 bytes Long
Public Const Flavor_f41 as UnsignedInteger = &H0226
Public Const PWControl_f41 as UnsignedInteger = &H0227
Public Const ReadPassword_f41 as UnsignedInteger = &H0228 '8 bytes (2xLongs)
Public Const FullPassword_f41 as UnsignedInteger = &H0230 '8 bytes (2xLongs)
Now within 8 of these bytes are these controls scattered across the bytes above
Code: Select all
Public Structure f41AllControls
Public SampleRate as UnsignedInteger
Public LowTempAlarm as Single
Public HighTempAlarm as Single
Public LowHumidAlarm as Single
Public HighHumidAlarm as Single
Public EnableTempHighAlarm as Boolean
Public EnableTempLowAlarm as Boolean
Public EnableHumidHighAlarm as Boolean
Public EnableHumidLowAlarm as Boolean
Public EnableHighSpeedSample as Boolean
Public EnableOscillator as Boolean
Public StartMissionOnTempAlarm as Boolean
Public RooloverActive as Boolean
Public HighResTemp as Boolean
Public HighResHumid as Boolean
Public EnableHumidLogging as Boolean
Public EnableTempLogging as Boolean
Public StartDelay as Long
Public PWcontrol as Boolean
End Structure
And within 6 of those bytes are these status Bits
Code: Select all
Public Structure f41Status
Public BatteryOnResetAlarm as Boolean
Public TempHighAlarm as Boolean
Public HumidHighAlarm as Boolean
Public TempLowAlarm as Boolean
Public HumidLowAlarm as Boolean
Public WaitForTempAlarm as Boolean
Public WaitForHumidAlarm as Boolean
Public MemoryCleared as Boolean
Public MissionInProgress as Boolean
End Structure
In addition there are informational R/O bytes such as Temperature, Humidity and Time that change quicker so are separate from Status.
The problem as I mentioned before is so much code is spent pulling the data together to make sense of it. Using GetBit and &B0010_0000 defines make the code unreadable. Can't variable names point to where the variables sit?
- - One handle or address for the top of the 32bit array.
- A name or address for each of the named bytes and
- Names for all the bit data.
So going back to your solution I would need to write this type of structure for each of the bytes.
Code: Select all
Union bar ( or maybe TempAlarmControl_f41 )
Public b as Byte
Public ba_blank0 as bit
Public ba_EnableTempHighAlarm as bit 'now we can address an alarm bit
Public ba_EnableTempLowAlarm as bit
Public ba_EnableHumidHighAlarm as bit
Public ba_EnableHumidLowAlarm as bit
Public ba_blank5 as bit
Public ba_blank6 as bit
Public ba_blank7 as bit
End Union
Then for each of the 32 Unions/bytes I would need to pull them together as an array. This is not as important since there would be only 2 places in the code where all the bytes would be read and written. So I could use a list instead of a loop.
Regards
Tim