Skip to content

Commit f719013

Browse files
committed
Add special support for writing bytes to waveforms
1 parent 6bd9407 commit f719013

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

softioc/builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def Action(name, **fields):
121121
'l': 'LONG', # int_
122122
'f': 'FLOAT', # single
123123
'd': 'DOUBLE', # float_
124-
# 'S': 'STRING', # str_
124+
# noqa 'S': 'STRING', # str_
125125

126126
# The following type codes are weakly supported by pretending that
127127
# they're related types.
@@ -138,7 +138,7 @@ def Action(name, **fields):
138138

139139
# Coverts FTVL string to numpy type
140140
DbfStringToNumpy = {
141-
# 'STRING': numpy.dtype('S40'), # Don't think we want this!
141+
# noqa 'STRING': numpy.dtype('S40'), # Don't think we want this!
142142
'CHAR': numpy.dtype('int8'),
143143
'UCHAR': numpy.dtype('uint8'),
144144
'SHORT': numpy.dtype('int16'),

softioc/device.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ class ao(ProcessDeviceSupportOut):
315315

316316

317317
def _require_waveform(value, dtype):
318+
if isinstance(value, bytes):
319+
# Special case hack for byte arrays. Surprisingly tricky:
320+
value = numpy.frombuffer(value, dtype = numpy.uint8)
318321
value = numpy.require(value, dtype = dtype)
319322
if value.shape == ():
320323
value.shape = (1,)

0 commit comments

Comments
 (0)