Skip to content

Commit

Permalink
Merge pull request #29 from petebachant/command
Browse files Browse the repository at this point in the history
Add `acsc.command` function
  • Loading branch information
petebachant authored Nov 13, 2024
2 parents 10fc5c3 + 27033b4 commit 1ae8eb5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion acspy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""A package for working with ACS motion controllers in Python."""

__version__ = "0.0.7"
__version__ = "0.0.8"
8 changes: 8 additions & 0 deletions acspy/acsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,14 @@ def setOutput(hcomm, port: int, bit: int, val: int, wait=SYNCHRONOUS):
call_acsc(acs.acsc_SetOutput, hcomm, port, bit, val, wait)


def command(hcomm, command: str, wait=SYNCHRONOUS):
"""Send a command to the ACS controller."""
cmd_with_return = (command + "\r").encode()
cmd_len = len(cmd_with_return)
cmd_buffer = ctypes.create_string_buffer(cmd_with_return)
return call_acsc(acs.acsc_Command, hcomm, cmd_buffer, cmd_len, wait)


def call_acsc(func, *args, **kwargs):
"""Wraps ACS library to handle errors."""
rv = func(*args, **kwargs)
Expand Down

0 comments on commit 1ae8eb5

Please sign in to comment.