Skip to content

Events on hislip - #626

Open
hb020 wants to merge 17 commits into
pyvisa:mainfrom
hb020:events-on-hislip
Open

Events on hislip#626
hb020 wants to merge 17 commits into
pyvisa:mainfrom
hb020:events-on-hislip

Conversation

@hb020

@hb020 hb020 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor
  • Closes Allow events via hislip #625
  • Executed black . && isort -c . && flake8 with no errors. -> Is this still valid? It seems outdated.
  • The change is fully covered by automated unit tests
  • Documented in docs/ as appropriate. -> Looking where this might fit.
  • Added an entry to the CHANGES file

@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.93023% with 75 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.44%. Comparing base (328408f) to head (b417372).

Files with missing lines Patch % Lines
pyvisa_py/protocols/hislip.py 59.30% 51 Missing and 19 partials ⚠️
pyvisa_py/tcpip.py 66.66% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #626      +/-   ##
==========================================
+ Coverage   48.19%   49.44%   +1.24%     
==========================================
  Files          33       33              
  Lines        5625     5853     +228     
  Branches      545      577      +32     
==========================================
+ Hits         2711     2894     +183     
- Misses       2865     2891      +26     
- Partials       49       68      +19     
Flag Coverage Δ
unittests 49.44% <70.93%> (+1.24%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hb020
hb020 marked this pull request as draft August 17, 2026 18:28
@hb020

hb020 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

oops, left some asserts in there. Will clean up

@hb020
hb020 marked this pull request as ready for review August 18, 2026 11:45
@hb020

hb020 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Don't like all those asserts, but there were already a fair amount of them, so I'll leave them.

@hb020 hb020 mentioned this pull request Aug 28, 2026
5 tasks
@hb020
hb020 marked this pull request as draft August 28, 2026 20:19
@hb020

hb020 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

will check any side effects of the latest merges

@hb020

hb020 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

@MatthieuDartiailh would you be OK with including the hislip locking handling (#635) in here? They are all to be handled in different parts of the code, so overview would still be possible. Would be easier for me, as it otherwise would mean sitting on 3 PRs that affect hislip. (and I have 2 more coming on VXI-11)

@MatthieuDartiailh

Copy link
Copy Markdown
Member

TBH this one is already large so I would prefer you do not add more. You could try a stacked PR to let Github handle more of the boring resync.

@hb020

hb020 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

OK. Will place the HiSLIP locking in another PR, based on this one.

@hb020
hb020 marked this pull request as ready for review August 29, 2026 13:50
@hb020

hb020 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

OK to go.

@MatthieuDartiailh MatthieuDartiailh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very partial review

Comment thread pyvisa_py/protocols/hislip.py Outdated
assert self.control_code == 0
assert self.payload_length == 0
self.vendor_id = struct.unpack("!4x4s8x", self.header)
self.vendor_id = struct.unpack("!4x4s8x", self.header)[0]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain ?

@hb020 hb020 Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import struct
a = b"1234567890123456"
struct.unpack("!4x4s8x", a)
>>>>> (b'5678',)
struct.unpack("!4x4s8x", a)[0]
>>>>> b'5678'

The last one we want (we want a simple string,). But when looking more at it, not sure if 4s is correct. Need to check. Later. Busy today.

@hb020 hb020 Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

improved

Comment thread pyvisa_py/tcpip.py Outdated

if "," in self.parsed.lan_device_name:
sub_address, port_str = self.parsed.lan_device_name.split(",")
parsed = cast(rname.TCPIPInstr, self.parsed)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cast should not be needed since the rname is defined with the proper type on the class

@hb020 hb020 Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed cast

Comment on lines +425 to +426
event_callback: Optional[Callable[[int], None]] = None,
interrupt_callback: Optional[Callable[[int], None]] = None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't the type of the argument be narrower (IntEnum) ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, message.control_code and message.message_parameter are not enums.

self._thread = threading.Thread(target=self._run, daemon=True)

def start(self) -> None:
if not self._thread.is_alive():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks dangerous, you cannot restart a thread.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That start is only called on init (line 722), just after the creation of the thread.

@hb020
hb020 marked this pull request as draft August 30, 2026 21:39
@hb020
hb020 marked this pull request as ready for review August 30, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow events via hislip

2 participants