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
f95a3736a0ec
Commit
f95a3736a0ec
authored
5 months ago
by
jfp
Browse files
Options
Downloads
Patches
Plain Diff
Clean code, use struct ptd_buf
parent
56bdbeabb0c4
No related branches found
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/_vmsptd.pyx
+35
-33
35 additions, 33 deletions
python/local/ovms_module/ovms/ptd/_vmsptd.pyx
python/local/ovms_module/ovms/ptd/ovptd.h
+13
-3
13 additions, 3 deletions
python/local/ovms_module/ovms/ptd/ovptd.h
with
48 additions
and
36 deletions
python/local/ovms_module/ovms/ptd/_vmsptd.pyx
+
35
−
33
View file @
f95a3736
...
...
@@ -66,6 +66,12 @@
void
*
va_range_ps_start_va
"
va_range$ps_start_va
"
void
*
va_range_ps_end_va
"
va_range$ps_end_va
"
ctypedef
struct
ptd_buf
:
unsigned
short
status
;
unsigned
short
len
;
char
buf
[];
ctypedef
struct
ptd_handler
:
unsigned
short
channel
int
nbpagelets
...
...
@@ -75,9 +81,9 @@
int
timer_status
int
read_start_read
int
maxbuf
char
*
read_buf
char
*
echo_buf
char
*
write_buf
ptd_buf
*
read_buf
ptd_buf
*
echo_buf
ptd_buf
*
write_buf
VA_RANGE
inadr
ctypedef
struct
DevChar
:
...
...
@@ -318,9 +324,9 @@
buflen
=
sizeof
(
charbuff
.
devchar
)
handler
.
handler
=
<
ptd_handler
*>
allocate_page_aligned_memory
(
allocsz
,
pgsize
)
ptrc
=
<
char
*>
handler
.
handler
+
pgsize
handler
.
handler
.
read_buf
=
ptrc
handler
.
handler
.
write_buf
=
ptrc
+
maxbuf
handler
.
handler
.
echo_buf
=
ptrc
+
2
*
maxbuf
handler
.
handler
.
read_buf
=
<
ptd_buf
*>
ptrc
handler
.
handler
.
write_buf
=
<
ptd_buf
*>
(
ptrc
+
maxbuf
)
handler
.
handler
.
echo_buf
=
<
ptd_buf
*>
(
ptrc
+
2
*
maxbuf
)
handler
.
handler
.
nbpagelets
=
nbpagelets
handler
.
handler
.
maxbuf
=
maxbuf
handler
.
handler
.
inadr
.
va_range_ps_start_va
=
ptrc
...
...
@@ -351,7 +357,7 @@
checkStatus
(
s
)
s
=
lib_free_ef
(
<
unsigned
int
*>&
(
handler
.
handler
.
efn
))
checkStatus
(
s
)
free_page_aligned_memory
(
handler
.
handler
.
read_buf
)
free_page_aligned_memory
(
<
char
*>
handler
.
handler
.
read_buf
)
return
s
def
readw
(
PtdHandler
handler
):
...
...
@@ -364,6 +370,6 @@
s
=
sys_hiber
()
s
=
SS__NORMAL
handler
.
handler
.
read_status
=
0
(
<
unsigned
short
*>
(
handler
.
handler
.
inadr
.
va_range_ps_start_va
))[
0
]
=
0
(
<
ptd_buf
*>
(
handler
.
handler
.
read_buf
)).
status
=
0
with
nogil
:
s
=
ptd_readw
(
EFN_C_ENF
,
handler
.
handler
.
channel
,
0
,
0
,
...
...
@@ -368,5 +374,5 @@
with
nogil
:
s
=
ptd_readw
(
EFN_C_ENF
,
handler
.
handler
.
channel
,
0
,
0
,
handler
.
handler
.
read_buf
,
<
char
*>
handler
.
handler
.
read_buf
,
handler
.
handler
.
maxbuf
-
4
)
checkStatus
(
s
)
...
...
@@ -371,5 +377,5 @@
handler
.
handler
.
maxbuf
-
4
)
checkStatus
(
s
)
s
=
(
<
unsigned
short
*>
(
handler
.
handler
.
read_buf
))
[
0
]
s
=
(
<
ptd_buf
*>
(
handler
.
handler
.
read_buf
))
.
status
checkStatus
(
s
)
handler
.
handler
.
read_status
=
0
...
...
@@ -374,8 +380,8 @@
checkStatus
(
s
)
handler
.
handler
.
read_status
=
0
cdef
char
*
buf
=
<
char
*>
(
handler
.
handler
.
read_buf
)
+
4
cdef
unsigned
short
*
retlen
Ptr
=
<
unsigned
short
*>
(
buf
-
2
)
return
s
,
buf
[:
retlen
Ptr
[
0
]
]
cdef
char
*
buf
=
<
char
*>
handler
.
handler
.
read_buf
.
buf
cdef
unsigned
short
retlen
=
(
<
ptd_buf
*>
(
handler
.
handler
.
read_buf
)).
len
return
s
,
buf
[:
retlen
]
def
read_timeout
(
PtdHandler
handler
,
short
timeout
):
"
status, res = read_timeout(handler, timeout)
\n\
...
...
@@ -403,6 +409,7 @@
# if a read request was not previously started, start one
if
handler
.
handler
.
read_status
==
0
:
handler
.
handler
.
read_status
=
1
(
<
ptd_buf
*>
(
handler
.
handler
.
read_buf
)).
status
=
0
with
nogil
:
s
=
ptd_read
(
EFN_C_ENF
,
handler
.
handler
.
channel
,
read_ast
,
<
int
>
handler
.
handler
,
...
...
@@ -406,7 +413,7 @@
with
nogil
:
s
=
ptd_read
(
EFN_C_ENF
,
handler
.
handler
.
channel
,
read_ast
,
<
int
>
handler
.
handler
,
handler
.
handler
.
read_buf
,
<
char
*>
handler
.
handler
.
read_buf
,
handler
.
handler
.
maxbuf
-
4
)
checkStatus
(
s
)
while
((
handler
.
handler
.
read_status
==
1
)
and
...
...
@@ -416,5 +423,5 @@
handler
.
handler
.
timer_status
=
0
handler
.
handler
.
read_status
=
0
return
SS__TIMEOUT
,
None
s
=
(
<
unsigned
short
*>
(
handler
.
handler
.
read_buf
))
[
0
]
s
=
(
<
ptd_buf
*>
(
handler
.
handler
.
read_buf
))
.
status
checkStatus
(
s
)
...
...
@@ -420,5 +427,5 @@
checkStatus
(
s
)
cdef
char
*
buf
=
<
char
*>
(
handler
.
handler
.
read_buf
)
+
4
cdef
unsigned
short
*
retlen
Ptr
=
<
unsigned
short
*>
(
buf
-
2
)
cdef
char
*
buf
=
<
char
*>
(
handler
.
handler
.
read_buf
.
buf
)
cdef
unsigned
short
retlen
=
(
<
ptd_buf
*>
(
handler
.
handler
.
read_buf
)).
len
handler
.
handler
.
timer_status
=
0
handler
.
handler
.
read_status
=
0
...
...
@@ -423,6 +430,6 @@
handler
.
handler
.
timer_status
=
0
handler
.
handler
.
read_status
=
0
return
s
,
buf
[:
retlen
Ptr
[
0
]
]
return
s
,
buf
[:
retlen
]
def
write
(
PtdHandler
handler
,
wrtstr
,
echo
=
False
):
"
status, res = write(handler, wrstr, echo=False)
"
...
...
@@ -434,9 +441,6 @@
with_echo
=
echo
if
wlen
>
handler
.
handler
.
maxbuf
-
4
:
raise
ValueError
(
f
'
Invalid wrtstr length, maximum is
{
handler
.
handler
.
maxbuf
-
4
}
'
)
cdef
char
*
wrtbuf
=
<
char
*>
(
handler
.
handler
.
write_buf
)
cdef
char
*
readbuf
=
\
<
char
*>
(
handler
.
handler
.
echo_buf
)
cdef
char
*
buf
=
<
char
*>
(
readbuf
)
+
4
cdef
unsigned
short
*
retlenPtr
=
<
unsigned
short
*>
(
buf
-
2
)
cdef
ptd_buf
*
wrtbuf
=
<
ptd_buf
*>
(
handler
.
handler
.
write_buf
)
cdef
ptd_buf
*
echobuf
=
<
ptd_buf
*>
(
handler
.
handler
.
echo_buf
)
memset
(
wrtbuf
,
4
,
0
)
...
...
@@ -442,7 +446,5 @@
memset
(
wrtbuf
,
4
,
0
)
strncpy
(
wrtbuf
+
4
,
wrtstrPtr
,
wlen
)
memset
(
readbuf
,
4
,
0
)
if
handler
.
handler
.
read_status
!=
0
:
cancel
(
handler
)
strncpy
(
<
char
*>
wrtbuf
+
4
,
wrtstrPtr
,
wlen
)
memset
(
echobuf
,
4
,
0
)
with
nogil
:
s
=
ptd_write
(
handler
.
handler
.
channel
,
0
,
0
,
...
...
@@ -447,5 +449,5 @@
with
nogil
:
s
=
ptd_write
(
handler
.
handler
.
channel
,
0
,
0
,
handler
.
handler
.
write_buf
,
wlen
,
read
buf
if
with_echo
else
NULL
,
<
char
*>
wrtbuf
,
wlen
,
<
char
*>
echo
buf
if
with_echo
else
NULL
,
handler
.
handler
.
maxbuf
-
4
if
with_echo
else
0
)
checkStatus
(
s
)
...
...
@@ -450,5 +452,5 @@
handler
.
handler
.
maxbuf
-
4
if
with_echo
else
0
)
checkStatus
(
s
)
s
=
(
<
unsigned
short
*>
(
wrtbuf
))[
0
]
s
=
wrtbuf
.
status
checkStatus
(
s
)
if
with_echo
:
...
...
@@ -453,4 +455,4 @@
checkStatus
(
s
)
if
with_echo
:
s
=
(
<
unsigned
short
*>
(
readbuf
))[
0
]
s
=
echobuf
.
status
checkStatus
(
s
)
...
...
@@ -456,6 +458,6 @@
checkStatus
(
s
)
return
s
,
buf
[:
retlenPtr
[
0
]
]
return
s
,
buf
[:
0
]
return
s
,
echobuf
.
buf
[:
echobuf
.
len
]
return
s
,
echobuf
.
buf
[:
0
]
def
set_event_notification
(
PtdHandler
handler
):
"
status = set_event_notification(handler)
"
...
...
This diff is collapsed.
Click to expand it.
python/local/ovms_module/ovms/ptd/ovptd.h
+
13
−
3
View file @
f95a3736
...
...
@@ -62,6 +62,16 @@
}
terminatorSetShortForm
;
#pragma __member_alignment __restore
#pragma __member_alignment __save
#pragma __nomember_alignment
typedef
struct
{
unsigned
short
status
;
unsigned
short
len
;
char
buf
[];
}
ptd_buf
;
typedef
volatile
ptd_buf
ptd_buf_volatile
;
#pragma __member_alignment __restore
typedef
volatile
struct
{
unsigned
short
channel
;
int
nbpagelets
;
...
...
@@ -73,9 +83,9 @@
1: the pseudoterminal is starting an
application's read request.*/
int
maxbuf
;
char
*
read_buf
;
char
*
echo_buf
;
char
*
write_buf
;
volatile
ptd_buf
*
read_buf
;
volatile
ptd_buf
*
echo_buf
;
volatile
ptd_buf
*
write_buf
;
VA_RANGE
inadr
;
}
ptd_handler
;
...
...
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