Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
vmspython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenVMS
Python
Modules
vmspython
Commits
844ac8a4167c
Commit
844ac8a4167c
authored
1 year ago
by
jfp
Browse files
Options
Downloads
Patches
Plain Diff
ptd.write: split string uing SYI__TTY_TYPAHDSZ (-8 to keep some margin)
parent
b0c87cce625d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/local/ovms_module/ovms/ptd/__init__.py
+15
-8
15 additions, 8 deletions
python/local/ovms_module/ovms/ptd/__init__.py
python/local/ovms_module/ovms/ptd/_vmsptd.pyx
+9
-0
9 additions, 0 deletions
python/local/ovms_module/ovms/ptd/_vmsptd.pyx
with
24 additions
and
8 deletions
python/local/ovms_module/ovms/ptd/__init__.py
+
15
−
8
View file @
844ac8a4
...
...
@@ -18,6 +18,6 @@
import
re
from
ovms.ssdef
import
SS__TIMEOUT
from
.
import
_vmsptd
from
ovms.rtl.lib
import
getdvi
,
spawn
from
ovms.rtl.lib
import
getdvi
,
spawn
,
getsyi
from
ovms.clidef
import
CLI_M_NOWAIT
from
ovms.dvidef
import
DVI__UNIT
...
...
@@ -22,5 +22,6 @@
from
ovms.clidef
import
CLI_M_NOWAIT
from
ovms.dvidef
import
DVI__UNIT
from
ovms.syidef
import
SYI__TTY_TYPAHDSZ
theNULL
=
chr
(
0
)
ESC
=
chr
(
27
)
...
...
@@ -193,6 +194,7 @@
row
:
int
column
:
int
_screen
:
List
[
List
[
str
]]
tty_typahdsz
:
int
=
0
def
__init__
(
self
,
...
...
@@ -236,6 +238,7 @@
flags
=
CLI_M_NOWAIT
,
prompt
=
prompt
,
)
Ptd
.
tty_typahdsz
=
getsyi
(
SYI__TTY_TYPAHDSZ
)[
1
]
def
close
(
self
):
"""
Forces the pseudoterminal to be deleted and frees the channel
"""
...
...
@@ -269,8 +272,11 @@
def
write
(
self
,
string
:
bytes
|
str
)
->
str
:
"""
Write to the pseudo terminal, return the echo string
"""
_
,
res
=
_vmsptd
.
write
(
self
.
ptd
,
string
)
wres
=
""
n
=
Ptd
.
tty_typahdsz
-
8
for
i
in
range
(
0
,
len
(
string
),
n
):
_
,
res
=
_vmsptd
.
write
(
self
.
ptd
,
string
[
i
:
i
+
n
])
if
isinstance
(
res
,
bytes
):
res
=
res
.
decode
(
"
iso-8859-15
"
)
elif
not
isinstance
(
res
,
str
):
raise
ValueError
(
"
Argument should be bytes or str
"
)
...
...
@@ -273,5 +279,6 @@
if
isinstance
(
res
,
bytes
):
res
=
res
.
decode
(
"
iso-8859-15
"
)
elif
not
isinstance
(
res
,
str
):
raise
ValueError
(
"
Argument should be bytes or str
"
)
wres
+=
res
self
.
_to_screen
(
res
)
...
...
@@ -277,5 +284,5 @@
self
.
_to_screen
(
res
)
return
res
return
w
res
def
writeln
(
self
,
string
:
bytes
|
str
):
"""
Write to the pseudo terminal the command and send a
'
\\
r
'
character
"""
...
...
This diff is collapsed.
Click to expand it.
python/local/ovms_module/ovms/ptd/_vmsptd.pyx
+
9
−
0
View file @
844ac8a4
...
...
@@ -282,6 +282,7 @@
def
create
(
unsigned
int
acmode
=
0
,
DeviceCharacteristics
charbuff
=
None
):
"
status, handler = create(acmode=0, charbuff=None)
"
cdef
unsigned
short
s
;
cdef
char
*
inadr
[
2
]
cdef
int
pgsize
=
sysconf
(
_SC_PAGE_SIZE
)
cdef
int
nbpages
=
<
int
>
(
6
*
pgsize
/
512
)
# 4 + 1 data + 1 guard pages
...
...
@@ -336,6 +337,7 @@
def
readw
(
PtdHandler
handler
):
"
status, res = readw(handler)
"
cdef
int
efn
=
EFN_C_ENF
cdef
unsigned
short
s
# if a read is already pending, wait for completion
if
handler
.
handler
.
read_status
!=
0
:
while
handler
.
handler
.
read_status
!=
2
:
...
...
@@ -347,6 +349,8 @@
handler
.
handler
.
inadr
.
va_range_ps_start_va
,
handler
.
handler
.
buflen
-
4
)
checkStatus
(
s
)
s
=
(
<
unsigned
short
*>
(
handler
.
handler
.
inadr
.
va_range_ps_start_va
))[
0
]
checkStatus
(
s
)
handler
.
handler
.
read_status
=
0
cdef
char
*
buf
=
<
char
*>
(
handler
.
handler
.
inadr
.
va_range_ps_start_va
)
+
4
cdef
unsigned
short
*
retlenPtr
=
<
unsigned
short
*>
(
buf
-
2
)
...
...
@@ -360,6 +364,7 @@
the command interprets the number as hundredths of a second.
\
For example, timeout=-20 specifies an interval of 20/100 or 1/5 of a second.
"
cdef
char
ascTime
[
10
]
cdef
unsigned
short
s
cdef
dsc_descriptor_s
ascTimeD
DESCSTR
(
ascTimeD
,
ascTime
)
cdef
unsigned
long
long
binTime
...
...
@@ -399,6 +404,7 @@
wrtstr
=
getstr
(
wrtstr
)
cdef
char
*
wrtstrPtr
=
wrtstr
cdef
int
wlen
=
len
(
wrtstr
)
cdef
unsigned
short
s
;
if
wlen
>
1024
:
raise
ValueError
(
'
Invalid wrtstr length, maximum is 1024
'
)
cdef
char
*
wrtbuf
=
<
char
*>
(
handler
.
handler
.
inadr
.
va_range_ps_start_va
)
...
...
@@ -413,9 +419,11 @@
handler
.
handler
.
inadr
.
va_range_ps_start_va
,
wlen
,
readbuf
,
handler
.
handler
.
buflen
-
1024
-
4
)
checkStatus
(
s
)
s
=
(
<
unsigned
short
*>
(
handler
.
handler
.
inadr
.
va_range_ps_start_va
))[
0
]
checkStatus
(
s
)
cdef
char
*
buf
=
<
char
*>
(
handler
.
handler
.
inadr
.
va_range_ps_start_va
)
+
4
cdef
unsigned
short
*
retlenPtr
=
<
unsigned
short
*>
(
buf
-
2
)
return
s
,
buf
[:
retlenPtr
[
0
]]
def
set_event_notification
(
PtdHandler
handler
):
"
status = set_event_notification(handler)
"
...
...
@@ -416,9 +424,10 @@
cdef
char
*
buf
=
<
char
*>
(
handler
.
handler
.
inadr
.
va_range_ps_start_va
)
+
4
cdef
unsigned
short
*
retlenPtr
=
<
unsigned
short
*>
(
buf
-
2
)
return
s
,
buf
[:
retlenPtr
[
0
]]
def
set_event_notification
(
PtdHandler
handler
):
"
status = set_event_notification(handler)
"
cdef
unsigned
short
s
;
s
=
ptd_set_event_notification
(
handler
.
handler
.
channel
,
NULL
,
0
,
0
,
PTD_C_ENABLE_READ
)
checkStatus
(
s
)
s
=
ptd_set_event_notification
(
handler
.
handler
.
channel
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment