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
9147bc13
Commit
9147bc13
authored
Apr 17, 2010
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IO objects and methods for GPIO
parent
09ddd39b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
505 additions
and
2 deletions
+505
-2
otherio/exp/rt/src/os_linux/hw_arm/makefile
otherio/exp/rt/src/os_linux/hw_arm/makefile
+50
-0
otherio/lib/rt/src/os_linux/hw_arm/makefile
otherio/lib/rt/src/os_linux/hw_arm/makefile
+15
-0
otherio/lib/rt/src/os_linux/rt_io_m_gpio.c
otherio/lib/rt/src/os_linux/rt_io_m_gpio.c
+93
-0
otherio/lib/rt/src/os_linux/rt_io_m_gpio.h
otherio/lib/rt/src/os_linux/rt_io_m_gpio.h
+14
-0
otherio/lib/rt/src/os_linux/rt_io_m_gpio_module.c
otherio/lib/rt/src/os_linux/rt_io_m_gpio_module.c
+188
-0
otherio/lib/rt/src/rt_io_otherio.meth
otherio/lib/rt/src/rt_io_otherio.meth
+2
-0
otherio/wbl/mcomp/src/otherio.wb_load
otherio/wbl/mcomp/src/otherio.wb_load
+143
-2
No files found.
otherio/exp/rt/src/os_linux/hw_arm/makefile
0 → 100644
View file @
9147bc13
include
$(pwre_dir_symbols)
ifndef
variables_mk
-include
$(pwre_croot)/src/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
endif
ifndef
variables_mk
include
$(pwre_croot)/src/tools/bld/src/$(os_name)/variables.mk
endif
ifndef
rules_mk
-include
$(pwre_croot)/src/tools/bld/src/$(os_name)/$(hw_name)/rules.mk
endif
ifndef
rules_mk
include
$(pwre_croot)/src/tools/bld/src/$(os_name)/rules.mk
endif
.PHONY
:
all init copy lib exe clean realclean
\
$(clean_c)
all
:
init copy lib
init
:
copy
:
$(inc_dir)/libusbio.h
lib
:
exe
:
clean
:
realclean
:
clean $(clean_obj)
.SUFFIXES
:
#$(lib_dir)/libusbio.a : ../libusbio.a
# @ echo "Copying libusbio.a"
# @ $(cp) $(cpflags) $(source) $(target)
$(inc_dir)/libusbio.h
:
../libusbio.h
@
echo
"Copying libusbio.h"
@
$(cp)
$(cpflags)
$(source)
$(target)
otherio/lib/rt/src/os_linux/hw_arm/makefile
0 → 100644
View file @
9147bc13
include
$(pwre_dir_symbols)
-include
$(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq
($($(type_name)_generic_mk),)
-include
$(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq
($($(type_name)_generic_mk),)
include
$(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include
../../special.mk
-include
../special.mk
-include
special.mk
otherio/lib/rt/src/os_linux/rt_io_m_gpio.c
0 → 100644
View file @
9147bc13
/*
* Proview $Id$
* 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.
*/
/* rt_io_m_gpio.c -- I/O methods for class GPIO. */
#include <stdio.h>
#include <stdlib.h>
#include "pwr.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "rt_io_base.h"
#include "rt_io_rack_init.h"
#include "rt_io_rack_close.h"
#include "rt_io_msg.h"
#include "rt_io_m_gpio.h"
static
pwr_tStatus
IoRackInit
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
)
{
io_sCard
*
cp
;
pwr_sClass_GPIO
*
op
=
(
pwr_sClass_GPIO
*
)
rp
->
op
;
FILE
*
fp
;
pwr_tStatus
sts
;
int
i
;
fp
=
fopen
(
"/sys/class/gpio/export"
,
"w"
);
if
(
!
fp
)
{
errh_Error
(
"GPIO unable to open
\"
/sys/class/gpio/export
\"
, %s"
,
rp
->
Name
);
sts
=
IO__INITFAIL
;
op
->
Status
=
sts
;
return
sts
;
}
for
(
cp
=
rp
->
cardlist
;
cp
;
cp
=
cp
->
next
)
{
for
(
i
=
0
;
i
<
GPIO_MAX_CHANNELS
;
i
++
)
{
if
(
cp
->
chanlist
[
i
].
cop
)
{
switch
(
cp
->
chanlist
[
i
].
ChanClass
)
{
case
pwr_cClass_ChanDi
:
fprintf
(
fp
,
"%u"
,
((
pwr_sClass_ChanDi
*
)
cp
->
chanlist
[
i
].
cop
)
->
Number
);
fflush
(
fp
);
break
;
case
pwr_cClass_ChanDo
:
fprintf
(
fp
,
"%u"
,
((
pwr_sClass_ChanDo
*
)
cp
->
chanlist
[
i
].
cop
)
->
Number
);
fflush
(
fp
);
break
;
default:
;
}
}
}
}
fclose
(
fp
);
errh_Info
(
"Init of GPIO '%s'"
,
rp
->
Name
);
op
->
Status
=
IO__SUCCESS
;
return
IO__SUCCESS
;
}
static
pwr_tStatus
IoRackClose
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
)
{
pwr_sClass_GPIO
*
op
=
(
pwr_sClass_GPIO
*
)
rp
->
op
;
op
->
Status
=
0
;
return
IO__SUCCESS
;
}
/* Every method should be registred here. */
pwr_dExport
pwr_BindIoMethods
(
GPIO
)
=
{
pwr_BindIoMethod
(
IoRackInit
),
pwr_BindIoMethod
(
IoRackClose
),
pwr_NullMethod
};
otherio/lib/rt/src/os_linux/rt_io_m_gpio.h
0 → 100644
View file @
9147bc13
/* ra_io_m_motioncontrol_usb.h -- I/O methods for class MotionControl_USBIO. */
#ifndef ra_io_m_gpio_h
#define ra_io_m_gpio_h
#define GPIO_MAX_CHANNELS 32
typedef
struct
{
FILE
*
value_fp
[
GPIO_MAX_CHANNELS
];
unsigned
int
number
[
GPIO_MAX_CHANNELS
];
int
scancount
;
}
io_sLocalGPIO_Module
;
#endif
otherio/lib/rt/src/os_linux/rt_io_m_gpio_module.c
0 → 100644
View file @
9147bc13
/*
* Proview $Id: rt_io_m_motioncontrol_usbio.c,v 1.1 2007-11-22 13:28:59 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.
*/
/* rt_io_m_motioncontrol_usbio.c -- I/O methods for class MotionControl_USBIO. */
#include "pwr.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "co_time.h"
#include "rt_io_base.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
#include "rt_io_card_write.h"
#include "rt_io_msg.h"
#include "rt_io_m_gpio.h"
static
pwr_tStatus
IoCardInit
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
int
i
;
pwr_sClass_GPIO_Module
*
op
=
(
pwr_sClass_GPIO_Module
*
)
cp
->
op
;
FILE
*
fp
;
char
str
[
80
];
io_sLocalGPIO_Module
*
local
;
char
direction
[
20
];
char
access
[
20
];
pwr_tStatus
sts
;
local
=
(
io_sLocalGPIO_Module
*
)
calloc
(
1
,
sizeof
(
io_sLocalGPIO_Module
));
cp
->
Local
=
local
;
for
(
i
=
0
;
i
<
GPIO_MAX_CHANNELS
;
i
++
)
{
if
(
cp
->
chanlist
[
i
].
cop
)
{
switch
(
cp
->
chanlist
[
i
].
ChanClass
)
{
case
pwr_cClass_ChanDi
:
local
->
number
[
i
]
=
((
pwr_sClass_ChanDi
*
)
cp
->
chanlist
[
i
].
cop
)
->
Number
;
strcpy
(
direction
,
"in"
);
strcpy
(
access
,
"r+"
);
break
;
case
pwr_cClass_ChanDo
:
local
->
number
[
i
]
=
((
pwr_sClass_ChanDo
*
)
cp
->
chanlist
[
i
].
cop
)
->
Number
;
strcpy
(
direction
,
"out"
);
strcpy
(
access
,
"w"
);
break
;
default:
;
}
switch
(
cp
->
chanlist
[
i
].
ChanClass
)
{
case
pwr_cClass_ChanDi
:
case
pwr_cClass_ChanDo
:
sprintf
(
str
,
"/sys/class/gpio/gpio%u/direction"
,
local
->
number
[
i
]);
fp
=
fopen
(
str
,
"w"
);
if
(
!
fp
)
{
errh_Error
(
"GPIO uable to open %s, %s, Id: %d"
,
str
,
cp
->
Name
,
local
->
number
[
i
]);
sts
=
IO__INITFAIL
;
op
->
Status
=
sts
;
return
sts
;
}
fprintf
(
fp
,
"%s"
,
direction
);
fclose
(
fp
);
sprintf
(
str
,
"/sys/class/gpio/gpio%u/value"
,
local
->
number
[
i
]);
local
->
value_fp
[
i
]
=
fopen
(
str
,
access
);
if
(
!
local
->
value_fp
[
i
])
{
errh_Error
(
"GPIO Unable op open %s, '%s' Id: %d"
,
str
,
cp
->
Name
,
local
->
number
[
i
]);
sts
=
IO__INITFAIL
;
op
->
Status
=
sts
;
return
sts
;
}
break
;
default:
;
}
}
}
errh_Info
(
"Init of GPIO Module '%s'"
,
cp
->
Name
);
return
IO__SUCCESS
;
}
static
pwr_tStatus
IoCardClose
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
int
i
;
io_sLocalGPIO_Module
*
local
=
(
io_sLocalGPIO_Module
*
)
cp
->
Local
;
for
(
i
=
0
;
i
<
GPIO_MAX_CHANNELS
;
i
++
)
{
if
(
cp
->
chanlist
[
i
].
cop
)
{
switch
(
cp
->
chanlist
[
i
].
ChanClass
){
case
pwr_cClass_ChanDi
:
case
pwr_cClass_ChanDo
:
if
(
local
->
value_fp
[
i
])
fclose
(
local
->
value_fp
[
i
]);
break
;
default:
;
}
}
}
free
(
cp
->
Local
);
return
IO__SUCCESS
;
}
static
pwr_tStatus
IoCardRead
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
io_sLocalGPIO_Module
*
local
=
(
io_sLocalGPIO_Module
*
)
cp
->
Local
;
int
i
;
char
str
[
20
];
for
(
i
=
0
;
i
<
GPIO_MAX_CHANNELS
;
i
++
)
{
if
(
cp
->
chanlist
[
i
].
cop
)
{
switch
(
cp
->
chanlist
[
i
].
ChanClass
)
{
case
pwr_cClass_ChanDi
:
fflush
(
local
->
value_fp
[
i
]);
fgets
(
str
,
sizeof
(
str
),
local
->
value_fp
[
i
]);
rewind
(
local
->
value_fp
[
i
]);
if
(
str
[
0
]
==
'0'
)
*
(
pwr_tBoolean
*
)
cp
->
chanlist
[
i
].
vbp
=
0
;
else
*
(
pwr_tBoolean
*
)
cp
->
chanlist
[
i
].
vbp
=
1
;
break
;
default:
;
}
}
}
return
IO__SUCCESS
;
}
static
pwr_tStatus
IoCardWrite
(
io_tCtx
ctx
,
io_sAgent
*
ap
,
io_sRack
*
rp
,
io_sCard
*
cp
)
{
io_sLocalGPIO_Module
*
local
=
(
io_sLocalGPIO_Module
*
)
cp
->
Local
;
int
i
;
for
(
i
=
0
;
i
<
GPIO_MAX_CHANNELS
;
i
++
)
{
if
(
cp
->
chanlist
[
i
].
cop
)
{
switch
(
cp
->
chanlist
[
i
].
ChanClass
)
{
case
pwr_cClass_ChanDo
:
if
(
*
(
pwr_tBoolean
*
)
cp
->
chanlist
[
i
].
vbp
)
fprintf
(
local
->
value_fp
[
i
],
"1"
);
else
fprintf
(
local
->
value_fp
[
i
],
"0"
);
fflush
(
local
->
value_fp
[
i
]);
// printf( "Write %d %d\n", local->number[i], *(pwr_tBoolean *)cp->chanlist[i].vbp);
break
;
default:
;
}
}
}
return
IO__SUCCESS
;
}
/* Every method should be registred here. */
pwr_dExport
pwr_BindIoMethods
(
GPIO_Module
)
=
{
pwr_BindIoMethod
(
IoCardInit
),
pwr_BindIoMethod
(
IoCardClose
),
pwr_BindIoMethod
(
IoCardRead
),
pwr_BindIoMethod
(
IoCardWrite
),
pwr_NullMethod
};
otherio/lib/rt/src/rt_io_otherio.meth
View file @
9147bc13
...
...
@@ -5,3 +5,5 @@ Modbus_Module
Modbus_Master
Modbus_TCP_Server
Modbus_TCP_ServerModule
GPIO
GPIO_Module
otherio/wbl/mcomp/src/otherio.wb_load
View file @
9147bc13
Volume OtherIO $ClassVolume 0.0.250.10
Body SysBody 01-JAN-1970 01:00:00.00
Attr NextOix = "_X
77
"
Attr NextCix = "_X
8
"
Attr NextOix = "_X
91
"
Attr NextCix = "_X
10
"
Attr NextTix[0] = "_X5"
EndBody
Object Type $TypeHier 1 15-NOV-2007 14:35:37.90
...
...
@@ -1452,5 +1452,146 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndBody
EndObject
EndObject
Object GPIO $ClassDef 8 15-APR-2010 21:46:30.11
Body SysBody 15-APR-2010 21:46:16.74
Attr Editor = 0
Attr Method = 0
Attr Flags = 10320
EndBody
Object RtBody $ObjBodyDef 1 15-APR-2010 21:46:16.74
Body SysBody 15-APR-2010 21:46:39.64
Attr StructName = "GPIO"
Attr NextAix = "_X17"
EndBody
Object Description $Attribute 13 15-APR-2010 21:46:16.74
Body SysBody 15-APR-2010 21:46:16.74
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object Process $Attribute 14 15-APR-2010 21:46:16.74
Body SysBody 15-APR-2010 21:54:44.41
Attr PgmName = "Process"
Attr TypeRef = "pwrb:Type-IoProcessMask"
EndBody
EndObject
Object ThreadObject $Attribute 15 15-APR-2010 21:46:16.74
Body SysBody 15-APR-2010 21:46:16.74
Attr PgmName = "ThreadObject"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
Object Status $Attribute 16 15-APR-2010 21:46:16.74
Body SysBody 15-APR-2010 21:55:29.27
Attr PgmName = "Status"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
EndObject
Object ConfiguratorPoson $Menu 78 15-APR-2010 21:46:16.74
Object Pointed $Menu 79 15-APR-2010 21:46:16.74
Object Connect $MenuButton 80 15-APR-2010 21:46:16.74
Body SysBody 15-APR-2010 21:46:16.74
Attr ButtonName = "Connect PlcThread"
Attr MethodName = "$Objid-Connect"
Attr MethodArguments[0] = "ThreadObject"
Attr MethodArguments[1] = "PlcThread"
Attr FilterName = "$Objid-IsOkConnect"
Attr FilterArguments[0] = "ThreadObject"
Attr FilterArguments[1] = "PlcThread"
EndBody
EndObject
EndObject
EndObject
Object IoMethods $RtMethod 89 15-APR-2010 21:52:17.62
Object IoRackInit $Method 90 15-APR-2010 21:52:17.62
Body SysBody 15-APR-2010 21:52:28.10
Attr MethodName = "GPIO-IoRackInit"
EndBody
EndObject
Object IoRackClose $Method 91 15-APR-2010 21:52:17.62
Body SysBody 15-APR-2010 21:52:39.12
Attr MethodName = "GPIO-IoRackClose"
EndBody
EndObject
EndObject
Object Template GPIO 2149810176 01-JAN-1970 01:00:00.00
Body RtBody 15-APR-2010 21:57:21.82
Attr Process = 1
EndBody
EndObject
EndObject
Object GPIO_Module $ClassDef 9 15-APR-2010 21:49:47.13
Body SysBody 15-APR-2010 21:46:16.74
Attr Editor = 0
Attr Method = 0
Attr Flags = 18512
EndBody
Object RtBody $ObjBodyDef 1 15-APR-2010 21:46:16.74
Body SysBody 15-APR-2010 21:52:59.99
Attr StructName = "GPIO_Module"
Attr NextAix = "_X15"
EndBody
Object Description $Attribute 10 15-APR-2010 21:53:54.03
Body SysBody 15-APR-2010 21:54:16.96
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object Process $Attribute 11 15-APR-2010 21:54:37.62
Body SysBody 15-APR-2010 21:54:53.56
Attr PgmName = "Process"
Attr TypeRef = "pwrb:Type-IoProcessMask"
EndBody
EndObject
Object ThreadObject $Attribute 13 15-APR-2010 21:55:05.81
Body SysBody 15-APR-2010 21:55:05.81
Attr PgmName = "ThreadObject"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
Object Status $Attribute 12 15-APR-2010 21:55:37.33
Body SysBody 15-APR-2010 21:55:45.30
Attr PgmName = "Status"
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
Object ScanInterval $Attribute 14 16-APR-2010 16:09:01.24
Body SysBody 16-APR-2010 16:09:02.20
Attr PgmName = "ScanInterval"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
EndObject
Object IoMethods $RtMethod 84 15-APR-2010 21:46:16.74
Object IoCardInit $Method 85 15-APR-2010 21:46:16.74
Body SysBody 15-APR-2010 21:55:58.78
Attr MethodName = "GPIO_Module-IoCardInit"
EndBody
EndObject
Object IoCardClose $Method 86 15-APR-2010 21:46:16.74
Body SysBody 15-APR-2010 21:56:07.31
Attr MethodName = "GPIO_Module-IoCardClose"
EndBody
EndObject
Object IoCardRead $Method 87 15-APR-2010 21:46:16.74
Body SysBody 15-APR-2010 21:56:12.67
Attr MethodName = "GPIO_Module-IoCardRead"
EndBody
EndObject
Object IoCardWrite $Method 88 15-APR-2010 21:46:16.74
Body SysBody 15-APR-2010 21:56:18.19
Attr MethodName = "GPIO_Module-IoCardWrite"
EndBody
EndObject
EndObject
Object Template GPIO_Module 2150072320 01-JAN-1970 01:00:00.00
Body RtBody 15-APR-2010 21:57:34.91
Attr Process = 1
Attr Status = 286
EndBody
EndObject
EndObject
EndObject
EndVolume
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