packages feed

sbp 6.0.0 → 6.0.1

raw patch · 3 files changed

+187/−1 lines, 3 files

Files

sbp.cabal view
@@ -1,5 +1,5 @@ name:                  sbp-version:               6.0.0+version:               6.0.1 synopsis:              SwiftNav's SBP Library homepage:              https://github.com/swift-nav/libsbp license:               MIT
src/SwiftNav/SBP/Msg.hs view
@@ -206,6 +206,9 @@    | SBPMsgPoseRelative MsgPoseRelative Msg    | SBPMsgPpsTime MsgPpsTime Msg    | SBPMsgPrintDep MsgPrintDep Msg+   | SBPMsgProfilingResourceCounter MsgProfilingResourceCounter Msg+   | SBPMsgProfilingSystemInfo MsgProfilingSystemInfo Msg+   | SBPMsgProfilingThreadInfo MsgProfilingThreadInfo Msg    | SBPMsgProtectionLevel MsgProtectionLevel Msg    | SBPMsgProtectionLevelDepA MsgProtectionLevelDepA Msg    | SBPMsgReferenceFrameParam MsgReferenceFrameParam Msg@@ -453,6 +456,9 @@           | _msgSBPType == msgPoseRelative = SBPMsgPoseRelative (decode (fromStrict (unBytes _msgSBPPayload))) m           | _msgSBPType == msgPpsTime = SBPMsgPpsTime (decode (fromStrict (unBytes _msgSBPPayload))) m           | _msgSBPType == msgPrintDep = SBPMsgPrintDep (decode (fromStrict (unBytes _msgSBPPayload))) m+          | _msgSBPType == msgProfilingResourceCounter = SBPMsgProfilingResourceCounter (decode (fromStrict (unBytes _msgSBPPayload))) m+          | _msgSBPType == msgProfilingSystemInfo = SBPMsgProfilingSystemInfo (decode (fromStrict (unBytes _msgSBPPayload))) m+          | _msgSBPType == msgProfilingThreadInfo = SBPMsgProfilingThreadInfo (decode (fromStrict (unBytes _msgSBPPayload))) m           | _msgSBPType == msgProtectionLevel = SBPMsgProtectionLevel (decode (fromStrict (unBytes _msgSBPPayload))) m           | _msgSBPType == msgProtectionLevelDepA = SBPMsgProtectionLevelDepA (decode (fromStrict (unBytes _msgSBPPayload))) m           | _msgSBPType == msgReferenceFrameParam = SBPMsgReferenceFrameParam (decode (fromStrict (unBytes _msgSBPPayload))) m@@ -692,6 +698,9 @@       encoder (SBPMsgPoseRelative _ m) = put m       encoder (SBPMsgPpsTime _ m) = put m       encoder (SBPMsgPrintDep _ m) = put m+      encoder (SBPMsgProfilingResourceCounter _ m) = put m+      encoder (SBPMsgProfilingSystemInfo _ m) = put m+      encoder (SBPMsgProfilingThreadInfo _ m) = put m       encoder (SBPMsgProtectionLevel _ m) = put m       encoder (SBPMsgProtectionLevelDepA _ m) = put m       encoder (SBPMsgReferenceFrameParam _ m) = put m@@ -935,6 +944,9 @@         | msgType == msgPoseRelative = SBPMsgPoseRelative <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj         | msgType == msgPpsTime = SBPMsgPpsTime <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj         | msgType == msgPrintDep = SBPMsgPrintDep <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj+        | msgType == msgProfilingResourceCounter = SBPMsgProfilingResourceCounter <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj+        | msgType == msgProfilingSystemInfo = SBPMsgProfilingSystemInfo <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj+        | msgType == msgProfilingThreadInfo = SBPMsgProfilingThreadInfo <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj         | msgType == msgProtectionLevel = SBPMsgProtectionLevel <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj         | msgType == msgProtectionLevelDepA = SBPMsgProtectionLevelDepA <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj         | msgType == msgReferenceFrameParam = SBPMsgReferenceFrameParam <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj@@ -1179,6 +1191,9 @@   toJSON (SBPMsgPoseRelative n m) = toJSON n <<>> toJSON m   toJSON (SBPMsgPpsTime n m) = toJSON n <<>> toJSON m   toJSON (SBPMsgPrintDep n m) = toJSON n <<>> toJSON m+  toJSON (SBPMsgProfilingResourceCounter n m) = toJSON n <<>> toJSON m+  toJSON (SBPMsgProfilingSystemInfo n m) = toJSON n <<>> toJSON m+  toJSON (SBPMsgProfilingThreadInfo n m) = toJSON n <<>> toJSON m   toJSON (SBPMsgProtectionLevel n m) = toJSON n <<>> toJSON m   toJSON (SBPMsgProtectionLevelDepA n m) = toJSON n <<>> toJSON m   toJSON (SBPMsgReferenceFrameParam n m) = toJSON n <<>> toJSON m@@ -1417,6 +1432,9 @@   msg f (SBPMsgPoseRelative n m) = SBPMsgPoseRelative n <$> f m   msg f (SBPMsgPpsTime n m) = SBPMsgPpsTime n <$> f m   msg f (SBPMsgPrintDep n m) = SBPMsgPrintDep n <$> f m+  msg f (SBPMsgProfilingResourceCounter n m) = SBPMsgProfilingResourceCounter n <$> f m+  msg f (SBPMsgProfilingSystemInfo n m) = SBPMsgProfilingSystemInfo n <$> f m+  msg f (SBPMsgProfilingThreadInfo n m) = SBPMsgProfilingThreadInfo n <$> f m   msg f (SBPMsgProtectionLevel n m) = SBPMsgProtectionLevel n <$> f m   msg f (SBPMsgProtectionLevelDepA n m) = SBPMsgProtectionLevelDepA n <$> f m   msg f (SBPMsgReferenceFrameParam n m) = SBPMsgReferenceFrameParam n <$> f m
src/SwiftNav/SBP/Profiling.hs view
@@ -91,3 +91,171 @@ $(makeSBP 'msgMeasurementPoint ''MsgMeasurementPoint) $(makeJSON "_msgMeasurementPoint_" ''MsgMeasurementPoint) $(makeLenses ''MsgMeasurementPoint)++msgProfilingSystemInfo :: Word16+msgProfilingSystemInfo = 0xCF01++-- | SBP class for message MSG_PROFILING_SYSTEM_INFO (0xCF01).+--+-- Contains basic information about system resource usage. System is defined+-- in terms of the source of this message and may vary from  sender to sender.+-- Refer to product documentation to understand the exact scope and meaning of+-- this message.+data MsgProfilingSystemInfo = MsgProfilingSystemInfo+  { _msgProfilingSystemInfo_total_cpu_time :: !Word64+    -- ^ Total cpu time in microseconds consumed by this system+  , _msgProfilingSystemInfo_age          :: !Word64+    -- ^ Age of the producing system in microseconds+  , _msgProfilingSystemInfo_n_threads    :: !Word8+    -- ^ Number of threads being tracked by this system+  , _msgProfilingSystemInfo_heap_usage   :: !Word32+    -- ^ Number of bytes allocated on the heap+  } deriving ( Show, Read, Eq )++instance Binary MsgProfilingSystemInfo where+  get = do+    _msgProfilingSystemInfo_total_cpu_time <- getWord64le+    _msgProfilingSystemInfo_age <- getWord64le+    _msgProfilingSystemInfo_n_threads <- getWord8+    _msgProfilingSystemInfo_heap_usage <- getWord32le+    pure MsgProfilingSystemInfo {..}++  put MsgProfilingSystemInfo {..} = do+    putWord64le _msgProfilingSystemInfo_total_cpu_time+    putWord64le _msgProfilingSystemInfo_age+    putWord8 _msgProfilingSystemInfo_n_threads+    putWord32le _msgProfilingSystemInfo_heap_usage++$(makeSBP 'msgProfilingSystemInfo ''MsgProfilingSystemInfo)+$(makeJSON "_msgProfilingSystemInfo_" ''MsgProfilingSystemInfo)+$(makeLenses ''MsgProfilingSystemInfo)++msgProfilingThreadInfo :: Word16+msgProfilingThreadInfo = 0xCF02++-- | SBP class for message MSG_PROFILING_THREAD_INFO (0xCF02).+--+-- Contains profiling information related to a single thread being tracked by+-- the producing system. Refer to product documentation to understand the+-- exact scope and meaning of this message.+data MsgProfilingThreadInfo = MsgProfilingThreadInfo+  { _msgProfilingThreadInfo_total_cpu_time :: !Word64+    -- ^ Total cpu time in microseconds consumed by this thread+  , _msgProfilingThreadInfo_age          :: !Word64+    -- ^ Age of the thread in microseconds+  , _msgProfilingThreadInfo_state        :: !Word8+    -- ^ Thread state+  , _msgProfilingThreadInfo_stack_size   :: !Word32+    -- ^ Stack size in bytes+  , _msgProfilingThreadInfo_stack_usage  :: !Word32+    -- ^ Stack high water usage in bytes+  , _msgProfilingThreadInfo_name         :: !Text+    -- ^ Thread name+  } deriving ( Show, Read, Eq )++instance Binary MsgProfilingThreadInfo where+  get = do+    _msgProfilingThreadInfo_total_cpu_time <- getWord64le+    _msgProfilingThreadInfo_age <- getWord64le+    _msgProfilingThreadInfo_state <- getWord8+    _msgProfilingThreadInfo_stack_size <- getWord32le+    _msgProfilingThreadInfo_stack_usage <- getWord32le+    _msgProfilingThreadInfo_name <- decodeUtf8 . toStrict <$> getRemainingLazyByteString+    pure MsgProfilingThreadInfo {..}++  put MsgProfilingThreadInfo {..} = do+    putWord64le _msgProfilingThreadInfo_total_cpu_time+    putWord64le _msgProfilingThreadInfo_age+    putWord8 _msgProfilingThreadInfo_state+    putWord32le _msgProfilingThreadInfo_stack_size+    putWord32le _msgProfilingThreadInfo_stack_usage+    putByteString $ encodeUtf8 _msgProfilingThreadInfo_name++$(makeSBP 'msgProfilingThreadInfo ''MsgProfilingThreadInfo)+$(makeJSON "_msgProfilingThreadInfo_" ''MsgProfilingThreadInfo)+$(makeLenses ''MsgProfilingThreadInfo)++-- | ResourceBucket.+--+-- Information about allocation of various resources grouped by buckets. Refer+-- to product documentation to understand the meaning and values in this+-- message.+data ResourceBucket = ResourceBucket+  { _resourceBucket_name           :: !Text+    -- ^ Bucket name+  , _resourceBucket_thread         :: !Word8+    -- ^ Number of threads+  , _resourceBucket_mutex          :: !Word8+    -- ^ Number of mutexes+  , _resourceBucket_cv             :: !Word8+    -- ^ Number of condition variables+  , _resourceBucket_io             :: !Word8+    -- ^ Number of IO handles+  , _resourceBucket_heap_bytes_alloc :: !Word32+    -- ^ Number of bytes allocated on the heap+  , _resourceBucket_heap_bytes_free :: !Word32+    -- ^ Number of bytes freed on the heap+  , _resourceBucket_io_write       :: !Word32+    -- ^ Number of bytes written to IO handles+  , _resourceBucket_io_read        :: !Word32+    -- ^ Number of bytes read from IO handles+  } deriving ( Show, Read, Eq )++instance Binary ResourceBucket where+  get = do+    _resourceBucket_name <- decodeUtf8 <$> getByteString 21+    _resourceBucket_thread <- getWord8+    _resourceBucket_mutex <- getWord8+    _resourceBucket_cv <- getWord8+    _resourceBucket_io <- getWord8+    _resourceBucket_heap_bytes_alloc <- getWord32le+    _resourceBucket_heap_bytes_free <- getWord32le+    _resourceBucket_io_write <- getWord32le+    _resourceBucket_io_read <- getWord32le+    pure ResourceBucket {..}++  put ResourceBucket {..} = do+    putByteString $ encodeUtf8 _resourceBucket_name+    putWord8 _resourceBucket_thread+    putWord8 _resourceBucket_mutex+    putWord8 _resourceBucket_cv+    putWord8 _resourceBucket_io+    putWord32le _resourceBucket_heap_bytes_alloc+    putWord32le _resourceBucket_heap_bytes_free+    putWord32le _resourceBucket_io_write+    putWord32le _resourceBucket_io_read++$(makeJSON "_resourceBucket_" ''ResourceBucket)+$(makeLenses ''ResourceBucket)++msgProfilingResourceCounter :: Word16+msgProfilingResourceCounter = 0xCF03++-- | SBP class for message MSG_PROFILING_RESOURCE_COUNTER (0xCF03).+--+-- Information about resource buckets. Refer to product documentation to+-- understand the meaning and values in this message.+data MsgProfilingResourceCounter = MsgProfilingResourceCounter+  { _msgProfilingResourceCounter_seq_no :: !Word8+    -- ^ Message number in complete sequence+  , _msgProfilingResourceCounter_seq_len :: !Word8+    -- ^ Length of message sequence+  , _msgProfilingResourceCounter_buckets :: ![ResourceBucket]+    -- ^ List of resource buckets+  } deriving ( Show, Read, Eq )++instance Binary MsgProfilingResourceCounter where+  get = do+    _msgProfilingResourceCounter_seq_no <- getWord8+    _msgProfilingResourceCounter_seq_len <- getWord8+    _msgProfilingResourceCounter_buckets <- whileM (not <$> isEmpty) get+    pure MsgProfilingResourceCounter {..}++  put MsgProfilingResourceCounter {..} = do+    putWord8 _msgProfilingResourceCounter_seq_no+    putWord8 _msgProfilingResourceCounter_seq_len+    mapM_ put _msgProfilingResourceCounter_buckets++$(makeSBP 'msgProfilingResourceCounter ''MsgProfilingResourceCounter)+$(makeJSON "_msgProfilingResourceCounter_" ''MsgProfilingResourceCounter)+$(makeLenses ''MsgProfilingResourceCounter)