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
a4c5315a
Commit
a4c5315a
authored
Feb 29, 2008
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New i/o-system for Modbus TCP implemented
parent
97e0cec3
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1020 additions
and
0 deletions
+1020
-0
otherio/lib/rt/src/os_linux/rt_io_m_mb_module.c
otherio/lib/rt/src/os_linux/rt_io_m_mb_module.c
+138
-0
otherio/lib/rt/src/os_linux/rt_io_m_mb_tcp_slave.c
otherio/lib/rt/src/os_linux/rt_io_m_mb_tcp_slave.c
+724
-0
otherio/lib/rt/src/os_linux/rt_io_mb_locals.h
otherio/lib/rt/src/os_linux/rt_io_mb_locals.h
+156
-0
otherio/lib/rt/src/rt_io_otherio.meth
otherio/lib/rt/src/rt_io_otherio.meth
+2
-0
No files found.
otherio/lib/rt/src/os_linux/rt_io_m_mb_module.c
0 → 100644
View file @
a4c5315a
/*
* Proview $Id: rt_io_m_mb_module.c,v 1.1 2008-02-29 08:01:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma pack(1)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include "rt_io_mb_locals.h"
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_errh.h"
#include "rt_io_bus.h"
#include "rt_mb_msg.h"
/*----------------------------------------------------------------------------*\
Init method for the Modbus module
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoCardInit
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
io_sCardLocal
*
local
;
pwr_sClass_Modbus_Module
*
op
;
int
i
;
op
=
(
pwr_sClass_Modbus_Module
*
)
cp
->
op
;
local
=
(
io_sCardLocal
*
)
cp
->
Local
;
for
(
i
=
0
;
i
<
IO_MAXCHAN
;
i
++
)
{
local
->
scancount
[
i
]
=
0
;
}
op
->
Status
=
pwr_eModbusModule_StatusEnum_StatusUnknown
;
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Read method for the Pb module
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoCardRead
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
io_sCardLocal
*
local
;
pwr_sClass_Modbus_Module
*
op
;
pwr_sClass_Modbus_TCP_Slave
*
slave
;
op
=
(
pwr_sClass_Modbus_Module
*
)
cp
->
op
;
local
=
(
io_sCardLocal
*
)
cp
->
Local
;
slave
=
(
pwr_sClass_Modbus_TCP_Slave
*
)
rp
->
op
;
if
(
slave
->
Status
==
MB__NORMAL
)
{
io_card_read
(
ctx
,
rp
,
cp
,
local
->
input_area
,
NULL
,
pwr_eByteOrderingEnum_BigEndian
,
pwr_eFloatRepEnum_FloatIntel
);
}
// printf("Method Modbus_Module-IoCardRead\n");
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Write method for the Pb module
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
IoCardWrite
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
io_sCardLocal
*
local
;
pwr_sClass_Modbus_Module
*
op
;
pwr_sClass_Modbus_TCP_Slave
*
slave
;
op
=
(
pwr_sClass_Modbus_Module
*
)
cp
->
op
;
local
=
(
io_sCardLocal
*
)
cp
->
Local
;
slave
=
(
pwr_sClass_Modbus_TCP_Slave
*
)
rp
->
op
;
if
(
slave
->
Status
==
MB__NORMAL
)
{
io_card_write
(
ctx
,
cp
,
local
->
output_area
,
pwr_eByteOrderingEnum_BigEndian
,
pwr_eFloatRepEnum_FloatIntel
);
}
// printf("Method Modbus_Module-IoCardWrite\n");
return
IO__SUCCESS
;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport
pwr_BindIoMethods
(
Modbus_Module
)
=
{
pwr_BindIoMethod
(
IoCardInit
),
pwr_BindIoMethod
(
IoCardRead
),
pwr_BindIoMethod
(
IoCardWrite
),
pwr_NullMethod
};
otherio/lib/rt/src/os_linux/rt_io_m_mb_tcp_slave.c
0 → 100644
View file @
a4c5315a
This diff is collapsed.
Click to expand it.
otherio/lib/rt/src/os_linux/rt_io_mb_locals.h
0 → 100644
View file @
a4c5315a
/*
* Proview $Id: rt_io_mb_locals.h,v 1.1 2008-02-29 08:01:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef pwr_class_h
#include "pwr_class.h"
#endif
#define IO_MAXCHAN 96
// These constants are obsolete from V4.1, except for the old style
// (Pb_Di, Pb_Do etc)
#define PB_MODULE_STATE_NOTINIT 0
#define PB_MODULE_STATE_OPERATE 1
//#define PB_SLAVE_STATE_NOTINIT 0
//#define PB_SLAVE_STATE_STOPPED 1
//#define PB_SLAVE_STATE_OPERATE 2
//#define PB_MASTER_STATE_NOTINIT 0
//#define PB_MASTER_STATE_STOPPED 1
//#define PB_MASTER_STATE_CLEARED 2
//#define PB_MASTER_STATE_OPERATE 3
//#define PB_STALLACTION_NONE 0
//#define PB_STALLACTION_RESET 1
//#define PB_STALLACTION_BREAK 2
#define PB_NUMREP_UNSIGNEDINT 0
#define PB_NUMREP_SIGNEDINT 1
#define PB_NUMREP_FLOATIEEE 2
#define PB_NUMREP_FLOATVAX 3
#define PB_NUMREP_FLOATINTEL 4
//#define PB_BYTEORDERING_LE 0
//#define PB_BYTEORDERING_BE 1
#define PB_ORIENTATION_BYTE 8
#define PB_ORIENTATION_WORD 16
#define PB_ORIENTATION_DWORD 32
#define PB_UDATA_DIAG 1
typedef
pwr_tMask
mb_tSendMask
;
typedef
enum
{
mb_mSendMask_ReadReq
=
1
,
mb_mSendMask_WriteReq
=
2
,
}
mb_mSendMask
;
typedef
struct
{
}
io_sAgentLocal
;
typedef
struct
{
int
initialized
;
int
s
;
short
int
trans_id
;
struct
sockaddr_in
rem_addr
;
/* Remote socket description */
struct
sockaddr_in
loc_addr
;
/* Remote socket description */
int
input_size
;
int
output_size
;
int
expected_msgs
;
}
io_sRackLocal
;
typedef
struct
{
void
*
input_area
;
void
*
output_area
;
int
scancount
[
IO_MAXCHAN
];
int
trans_id
;
int
input_size
;
int
output_size
;
short
int
no_di
;
short
int
no_do
;
}
io_sCardLocal
;
#pragma pack(1)
typedef
struct
{
unsigned
char
protocol_id
[
2
];
short
int
msg_size
;
short
int
msg_id
[
2
];
}
remote_tcp_header
;
typedef
struct
_mbap_header
{
short
int
trans_id
;
short
int
proto_id
;
short
int
length
;
unsigned
char
unit_id
;
}
mbap_header
;
typedef
struct
_read_req
{
mbap_header
head
;
unsigned
char
fc
;
short
int
addr
;
short
int
quant
;
}
read_req
;
typedef
struct
_rec_buf
{
mbap_header
head
;
short
int
buf
[
1000
];
}
rec_buf
;
typedef
struct
_write_reg_req
{
mbap_header
head
;
unsigned
char
fc
;
short
int
addr
;
short
int
quant
;
unsigned
char
bc
;
short
int
reg
[
125
];
}
write_reg_req
;
typedef
struct
_write_coils_req
{
mbap_header
head
;
unsigned
char
fc
;
short
int
addr
;
short
int
quant
;
unsigned
char
bc
;
unsigned
char
reg
[
250
];
}
write_coils_req
;
typedef
struct
_res_write
{
unsigned
char
fc
;
short
int
addr
;
short
int
quant
;
short
int
buf
[
250
];
}
res_write
;
typedef
struct
_res_read
{
unsigned
char
fc
;
unsigned
char
bc
;
short
int
buf
[
250
];
}
res_read
;
typedef
struct
_res_fault
{
unsigned
char
fc
;
unsigned
char
ec
;
}
res_fault
;
#pragma pack(0)
otherio/lib/rt/src/rt_io_otherio.meth
View file @
a4c5315a
MotionControl_USB
MotionControl_USBIO
Modbus_TCP_Slave
Modbus_Module
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