@@ -346,6 +346,13 @@ def _register_basic_callbacks(self):
346346
347347 self .register_config_callback (CBPacketType .CHANREPAINP , self ._handle_chaninfo )
348348 self .register_config_callback (CBPacketType .CHANREPSPKTHR , self ._handle_chaninfo )
349+ self .register_config_callback (
350+ CBPacketType .CHANREPNTRODEGROUP , self ._handle_chaninfo
351+ )
352+ self .register_config_callback (CBPacketType .CHANREPDISP , self ._handle_chaninfo )
353+ self .register_config_callback (
354+ CBPacketType .CHANREPUNITOVERRIDES , self ._handle_chaninfo
355+ )
349356
350357 self .register_config_callback (CBPacketType .GROUPREP , self ._handle_groupinfo )
351358 self .register_config_callback (CBPacketType .PROCREP , self ._handle_procinfo )
@@ -397,8 +404,10 @@ def _handle_sysrep(self, pkt):
397404 def _handle_chaninfo (self , pkt ):
398405 # If this config packet is limited in scope then it might have some garbage data in its out-of-scope payload.
399406 # We should update our config, but only the parts that this REP packet is scoped to.
400- if pkt .header .instrument != self ._config ["instrument" ]:
401- # Gemini system returns channel info for all instruments.
407+ if (pkt .header .instrument != self ._config ["instrument" ]) or (
408+ pkt .chan > self ._config ["proc_chans" ]
409+ ):
410+ # Drop channels that do not belong to this instrument
402411 pass
403412 elif pkt .header .type in [CBPacketType .CHANREP ]:
404413 # Full scope; overwrite our config.
@@ -430,8 +439,8 @@ def _handle_chaninfo(self, pkt):
430439 # self._config["channel_infos"][pkt.chan].union.a.moninst = pkt.moninst
431440 # self._config["channel_infos"][pkt.chan].union.a.monchan = pkt.monchan
432441 elif pkt .header .type == CBPacketType .CHANREPSCALE :
433- self ._config ["channel_infos" ][pkt .chan ].scalein = pkt .scalein
434- self ._config ["channel_infos" ][pkt .chan ].scaleout = pkt .scaleout
442+ self ._config ["channel_infos" ][pkt .chan ].scalin = pkt .scalin
443+ self ._config ["channel_infos" ][pkt .chan ].scalout = pkt .scalout
435444 elif pkt .header .type == CBPacketType .CHANREPDINP :
436445 # TODO: NOTE: Need extra check if this is for serial or digital?
437446 self ._config ["channel_infos" ][pkt .chan ].dinpopts = pkt .dinpopts
@@ -443,14 +452,21 @@ def _handle_chaninfo(self, pkt):
443452 elif pkt .header .type == CBPacketType .CHANREPLABEL :
444453 self ._config ["channel_infos" ][pkt .chan ].label = pkt .label
445454 self ._config ["channel_infos" ][pkt .chan ].userflags = pkt .userflags
446- elif pkt .header .type == CBPacketType .CHANSETSPKTHR :
447- # TODO: from CHANREPSPKTHR, .spkthrlevel
455+ elif pkt .header .type in [
456+ CBPacketType .CHANSETSPKTHR ,
457+ CBPacketType .CHANREPSPKTHR ,
458+ ]:
448459 self ._config ["channel_infos" ][pkt .chan ].spkthrlevel = pkt .spkthrlevel
449-
460+ elif pkt .header .type == CBPacketType .CHANREPNTRODEGROUP :
461+ # TODO: from use pkt.spkgroup
462+ pass
463+ elif pkt .header .type == CBPacketType .CHANREPDISP :
464+ # TODO: Use .smpdispmin, .smpdispmax, .spkdispmax, .lncdispmax
465+ pass
466+ elif pkt .header .type == CBPacketType .CHANREPUNITOVERRIDES :
467+ # TODO: Use .unitmapping
468+ pass
450469 else :
451- # TODO: from CHANREPNTRODEGROUP, .spkgroup
452- # TODO: from CHANREPDISP, .smpdispmin, .smpdispmax, .spkdispmax, .lncdispmax
453- # TODO: from CHANREPUNITOVERRIDES, .unitmapping
454470 pass
455471 # print(f"handled chaninfo {pkt.chan} of type {hex(pkt.header.type)}")
456472 self ._config_events ["chaninfo" ].set ()
@@ -479,6 +495,8 @@ def _handle_nplay(self, pkt):
479495
480496 def _handle_procmon (self , pkt ):
481497 arrival_time = time .time ()
498+ # Note: There's about 0.57 msec from when procmon is sent to when it is received.
499+ # so we could make sys_time = arrival_time - 570_000e-9
482500 update_interval = max (pkt .header .time - self ._monitor_state ["time" ], 1 )
483501 pkt_delta = self .pkts_received - self ._monitor_state ["pkts_received" ]
484502
@@ -493,7 +511,7 @@ def _handle_procmon(self, pkt):
493511 f";\t counter - { pkt .counter if has_counter else 'N/A' } "
494512 f";\t delta - { pkt_delta } "
495513 f";\t sent - { pkt .sentpkts } "
496- f";\t rate (pkt/samp) - { pkt_delta / update_interval } "
514+ f";\t rate (pkt/samp) - { pkt_delta / update_interval } "
497515 )
498516 self ._monitor_state = {
499517 "counter" : pkt .counter if has_counter else - 1 ,
0 commit comments