Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hcana
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Whitney Armstrong
hcana
Commits
8e9a4f85
Commit
8e9a4f85
authored
5 years ago
by
Chao
Committed by
Chao1009
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add a Write function to PRadETChannel class
parent
ba9c177c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/PRadETChannel.cxx
+55
-5
55 additions, 5 deletions
src/PRadETChannel.cxx
src/PRadETChannel.h
+1
-0
1 addition, 0 deletions
src/PRadETChannel.h
with
56 additions
and
5 deletions
src/PRadETChannel.cxx
+
55
−
5
View file @
8e9a4f85
...
...
@@ -149,15 +149,15 @@ bool PRadETChannel::Read()
return
false
;
case
ET_ERROR_DEAD
:
throw
(
PRadException
(
PRadException
::
ET_READ_ERROR
,
"et_client: et is dead!"
));
case
ET_ERROR_TIMEOUT
:
case
ET_ERROR_TIMEOUT
:
throw
(
PRadException
(
PRadException
::
ET_READ_ERROR
,
"et_client: got timeout!!"
));
case
ET_ERROR_BUSY
:
case
ET_ERROR_BUSY
:
throw
(
PRadException
(
PRadException
::
ET_READ_ERROR
,
"et_client: station is busy!"
));
case
ET_ERROR_WAKEUP
:
case
ET_ERROR_WAKEUP
:
throw
(
PRadException
(
PRadException
::
ET_READ_ERROR
,
"et_client: someone told me to wake up."
));
default:
default:
throw
(
PRadException
(
PRadException
::
ET_READ_ERROR
,
"et_client: unkown error!"
));
}
}
// copy the data buffer
copyEvent
();
...
...
@@ -178,6 +178,56 @@ bool PRadETChannel::Read()
return
true
;
}
bool
PRadETChannel
::
Write
(
void
*
buf
,
int
nbytes
)
{
// check if et is opened or alive
if
(
et_id
==
nullptr
||
!
et_alive
(
et_id
))
throw
(
PRadException
(
PRadException
::
ET_READ_ERROR
,
"et_client: et is not opened or dead!"
));
et_att_id
att
=
curr_stat
->
GetAttachID
();
int
status
=
et_event_new
(
et_id
,
att
,
&
etEvent
,
ET_SLEEP
,
nullptr
,
nbytes
);
switch
(
status
)
{
case
ET_OK
:
break
;
case
ET_ERROR_EMPTY
:
return
false
;
case
ET_ERROR_DEAD
:
throw
(
PRadException
(
PRadException
::
ET_READ_ERROR
,
"et_client: et is dead!"
));
case
ET_ERROR_TIMEOUT
:
throw
(
PRadException
(
PRadException
::
ET_READ_ERROR
,
"et_client: got timeout!!"
));
case
ET_ERROR_BUSY
:
throw
(
PRadException
(
PRadException
::
ET_READ_ERROR
,
"et_client: station is busy!"
));
case
ET_ERROR_WAKEUP
:
throw
(
PRadException
(
PRadException
::
ET_READ_ERROR
,
"et_client: someone told me to wake up."
));
default:
throw
(
PRadException
(
PRadException
::
ET_READ_ERROR
,
"et_client: unkown error!"
));
}
// build et event
void
*
data
;
et_event_getdata
(
etEvent
,
&
data
);
memcpy
((
void
*
)
data
,
(
const
void
*
)
buf
,
nbytes
);
et_event_setlength
(
etEvent
,
nbytes
);
// put back the event
status
=
et_event_put
(
et_id
,
att
,
etEvent
);
switch
(
status
)
{
case
ET_OK
:
break
;
case
ET_ERROR_DEAD
:
throw
(
PRadException
(
PRadException
::
ET_READ_ERROR
,
"et_client: et is dead!"
));
default:
throw
(
PRadException
(
PRadException
::
ET_READ_ERROR
,
"et_client: unkown error!"
));
}
return
true
;
}
void
PRadETChannel
::
copyEvent
()
{
void
*
data
;
...
...
This diff is collapsed.
Click to expand it.
src/PRadETChannel.h
+
1
−
0
View file @
8e9a4f85
...
...
@@ -57,6 +57,7 @@ public:
void
DetachStation
();
void
ForceClose
();
bool
Read
();
bool
Write
(
void
*
buf
,
int
nbytes
);
void
*
GetBuffer
()
{
return
(
void
*
)
buffer
;}
size_t
GetBufferLength
()
{
return
bufferSize
;}
Configuration
&
GetConfig
()
{
return
config
;}
...
...
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