Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
0d5e18d6
Commit
0d5e18d6
authored
Jun 02, 2006
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
parent
2f3de648
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
24 deletions
+41
-24
ssabox/lib/rt/src/os_linux/rt_io_m_ssab_remoterack.c
ssabox/lib/rt/src/os_linux/rt_io_m_ssab_remoterack.c
+41
-24
No files found.
ssabox/lib/rt/src/os_linux/rt_io_m_ssab_remoterack.c
View file @
0d5e18d6
/*
* Proview $Id: rt_io_m_ssab_remoterack.c,v 1.
3 2006-04-12 12:14:38
claes Exp $
* Proview $Id: rt_io_m_ssab_remoterack.c,v 1.
4 2006-06-02 07:14:29
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
...
...
@@ -65,21 +65,23 @@ static pwr_tStatus IoRackInit (
return
IO__ERRINIDEVICE
;
}
/*
Set local port same as remote port and bind the created socket
*/
/*
Bind local port if explicitly numbered ( != 0 )
*/
local
->
my_addr
.
sin_family
=
AF_INET
;
local
->
my_addr
.
sin_port
=
htons
(
op
->
Port
);
sts
=
bind
(
local
->
s
,
(
struct
sockaddr
*
)
&
local
->
my_addr
,
sizeof
(
local
->
my_addr
));
if
(
sts
!=
0
)
{
errh_Error
(
"Error binding local socket for IO remote rack %s, %d"
,
rp
->
Name
,
sts
);
op
->
Status
=
IO__INITFAIL
;
return
IO__ERRINIDEVICE
;
if
(
op
->
LocalPort
!=
0
)
{
local
->
my_addr
.
sin_family
=
AF_INET
;
local
->
my_addr
.
sin_port
=
htons
(
op
->
LocalPort
);
sts
=
bind
(
local
->
s
,
(
struct
sockaddr
*
)
&
local
->
my_addr
,
sizeof
(
local
->
my_addr
));
if
(
sts
!=
0
)
{
errh_Error
(
"Error binding local socket for IO remote rack %s, %d"
,
rp
->
Name
,
sts
);
op
->
Status
=
IO__INITFAIL
;
return
IO__ERRINIDEVICE
;
}
}
/* Initialize remote address structure */
local
->
rem_addr
.
sin_family
=
AF_INET
;
local
->
rem_addr
.
sin_port
=
htons
(
op
->
Port
);
local
->
rem_addr
.
sin_port
=
htons
(
op
->
Remote
Port
);
local
->
rem_addr
.
sin_addr
.
s_addr
=
inet_addr
((
char
*
)
&
(
op
->
Address
));
/* Connect to remote address */
...
...
@@ -91,17 +93,16 @@ static pwr_tStatus IoRackInit (
return
IO__ERRINIDEVICE
;
}
local
->
in_items
=
0
;
local
->
out_items
=
0
;
local
->
next_read_req_item
=
0
;
local
->
next_write_req_item
=
0
;
op
->
RX_packets
=
0
;
op
->
TX_packets
=
0
;
/* Log initialization */
errh_Info
(
"Init of IO remote rack %s, %d/%s:%d"
,
rp
->
Name
,
ntohs
(
local
->
my_addr
.
sin_port
),
inet_ntoa
(
local
->
rem_addr
.
sin_addr
),
ntohs
(
local
->
rem_addr
.
sin_port
));
errh_Info
(
"Init of IO remote rack %s/%s:%d"
,
rp
->
Name
,
inet_ntoa
(
local
->
rem_addr
.
sin_addr
),
ntohs
(
local
->
rem_addr
.
sin_port
));
op
->
Status
=
IO__NORMAL
;
return
IO__SUCCESS
;
}
...
...
@@ -127,6 +128,11 @@ static pwr_tStatus IoRackRead (
struct
timeval
tv
;
io_sRackLocal
*
local
=
(
io_sRackLocal
*
)
rp
->
Local
;
pwr_sClass_Ssab_RemoteRack
*
op
=
(
pwr_sClass_Ssab_RemoteRack
*
)
rp
->
op
;
struct
bfb_buf
rbuf
;
int
size
;
bzero
(
&
local
->
read_area
,
sizeof
(
local
->
read_area
));
bzero
(
&
local
->
write_area
,
sizeof
(
local
->
write_area
));
sts
=
1
;
while
(
sts
>
0
)
{
...
...
@@ -136,7 +142,15 @@ static pwr_tStatus IoRackRead (
tv
.
tv_usec
=
0
;
sts
=
select
(
32
,
&
fds
,
NULL
,
NULL
,
&
tv
);
if
(
sts
>
0
)
{
recv
(
local
->
s
,
&
local
->
in
,
sizeof
(
local
->
in
),
0
);
size
=
recv
(
local
->
s
,
&
rbuf
,
sizeof
(
rbuf
),
0
);
if
(
rbuf
.
service
==
BFB_SERVICE_READ
)
{
bzero
(
&
local
->
read_area
,
sizeof
(
local
->
read_area
));
memcpy
(
&
local
->
read_area
,
&
rbuf
,
size
);
}
else
if
(
rbuf
.
service
==
BFB_SERVICE_WRITE
)
{
bzero
(
&
local
->
write_area
,
sizeof
(
local
->
write_area
));
memcpy
(
&
local
->
write_area
,
&
rbuf
,
size
);
}
op
->
RX_packets
++
;
}
}
...
...
@@ -154,17 +168,20 @@ static pwr_tStatus IoRackWrite (
io_sRackLocal
*
local
=
(
io_sRackLocal
*
)
rp
->
Local
;
pwr_sClass_Ssab_RemoteRack
*
op
=
(
pwr_sClass_Ssab_RemoteRack
*
)
rp
->
op
;
//
S
end write request
local
->
out
.
service
=
BFB_SERVICE_WRITE
;
local
->
out
.
length
=
local
->
out_items
*
4
+
4
;
sts
=
send
(
local
->
s
,
&
local
->
out
,
local
->
out
.
length
,
0
);
//
Calc length and s
end write request
local
->
write_req
.
service
=
BFB_SERVICE_WRITE
;
local
->
write_req
.
length
=
local
->
next_write_req_item
*
4
+
4
;
sts
=
send
(
local
->
s
,
&
local
->
write_req
,
local
->
write_req
.
length
,
0
);
op
->
TX_packets
++
;
//
S
end read request
local
->
in
.
service
=
BFB_SERVICE_READ
;
local
->
in
.
length
=
local
->
in_items
*
4
+
4
;
sts
=
send
(
local
->
s
,
&
local
->
in
,
local
->
in
.
length
,
0
);
//
Calc length and s
end read request
local
->
read_req
.
service
=
BFB_SERVICE_READ
;
local
->
read_req
.
length
=
local
->
next_read_req_item
*
4
+
4
;
sts
=
send
(
local
->
s
,
&
local
->
read_req
,
local
->
read_req
.
length
,
0
);
op
->
TX_packets
++
;
local
->
next_read_req_item
=
0
;
local
->
next_write_req_item
=
0
;
return
IO__SUCCESS
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment