Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
e2d9b1a5
Commit
e2d9b1a5
authored
Feb 17, 2012
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(io): Исправил ошибку в кофигурировании аналоговых входов/выходов
parent
fadef5da
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
13 deletions
+43
-13
libuniset.spec
conf/libuniset.spec
+4
-1
ComediInterface.cc
extensions/IOControl/ComediInterface.cc
+6
-3
iotest.cc
extensions/IOControl/iotest.cc
+33
-9
No files found.
conf/libuniset.spec
View file @
e2d9b1a5
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
Name: libuniset
Name: libuniset
Version: 1.3
Version: 1.3
Release: alt
5
Release: alt
6
Summary: UniSet - library for building distributed industrial control systems
Summary: UniSet - library for building distributed industrial control systems
License: GPL
License: GPL
Group: Development/C++
Group: Development/C++
...
@@ -213,6 +213,9 @@ rm -f %buildroot%_libdir/*.la
...
@@ -213,6 +213,9 @@ rm -f %buildroot%_libdir/*.la
%changelog
%changelog
* Fri Feb 17 2012 Pavel Vainerman <pv@altlinux.ru> 1.3-alt6
- (io): corrected a mistake in configuring analog I/O
* Fri Feb 10 2012 Pavel Vainerman <pv@altlinux.ru> 1.3-alt5
* Fri Feb 10 2012 Pavel Vainerman <pv@altlinux.ru> 1.3-alt5
- (IOControl): Added support for setting boards such as 'Grayhill'
- (IOControl): Added support for setting boards such as 'Grayhill'
- (Modbus): Fixed minor bug in configuration with RTU188
- (Modbus): Fixed minor bug in configuration with RTU188
...
...
extensions/IOControl/ComediInterface.cc
View file @
e2d9b1a5
...
@@ -108,14 +108,17 @@ void ComediInterface::configureChannel( int subdev, int channel, ChannelType t,
...
@@ -108,14 +108,17 @@ void ComediInterface::configureChannel( int subdev, int channel, ChannelType t,
case
ComediInterface
:
:
AI
:
case
ComediInterface
:
:
AI
:
case
ComediInterface
:
:
AO
:
case
ComediInterface
:
:
AO
:
{
{
lsampl_t
data
[
2
];
comedi_insn
insn
;
comedi_insn
insn
;
lsampl_t
iotype
=
t
;
memset
(
&
insn
,
0
,
sizeof
(
insn
));
memset
(
&
insn
,
0
,
sizeof
(
insn
));
insn
.
insn
=
INSN_CONFIG
;
insn
.
insn
=
INSN_CONFIG
;
insn
.
n
=
1
;
insn
.
n
=
2
;
insn
.
data
=
&
iotype
;
insn
.
data
=
data
;
insn
.
subdev
=
subdev
;
insn
.
subdev
=
subdev
;
insn
.
chanspec
=
CR_PACK
(
channel
,
range
,
aref
);
insn
.
chanspec
=
CR_PACK
(
channel
,
range
,
aref
);
data
[
0
]
=
t
;
data
[
1
]
=
t
;
if
(
comedi_do_insn
(
card
,
&
insn
)
<
0
)
if
(
comedi_do_insn
(
card
,
&
insn
)
<
0
)
{
{
ostringstream
err
;
ostringstream
err
;
...
...
extensions/IOControl/iotest.cc
View file @
e2d9b1a5
...
@@ -83,6 +83,11 @@ int main(int argc, char* argv[])
...
@@ -83,6 +83,11 @@ int main(int argc, char* argv[])
printf
(
"[--range] val - RANGE (Default: %d)
\n
"
,
range
);
printf
(
"[--range] val - RANGE (Default: %d)
\n
"
,
range
);
printf
(
"[-p|--plus] chan - Add channel for command.
\n
"
);
printf
(
"[-p|--plus] chan - Add channel for command.
\n
"
);
printf
(
"[-a|--autoconf] - autoconf channel type
\n
"
);
printf
(
"[-a|--autoconf] - autoconf channel type
\n
"
);
printf
(
"[-c|--config] chan type - Set 'type' for 'chan'.
\n
"
);
printf
(
" %3d - DI
\n
"
,
INSN_CONFIG_DIO_INPUT
);
printf
(
" %3d - DO
\n
"
,
INSN_CONFIG_DIO_OUTPUT
);
printf
(
" %3d - AI
\n
"
,
100
);
printf
(
" %3d - AO
\n
"
,
101
);
printf
(
"[-q|--subdev-config] - subdev type configure
\n
"
);
printf
(
"[-q|--subdev-config] - subdev type configure
\n
"
);
printf
(
" 1 - TBI 24/0
\n
"
);
printf
(
" 1 - TBI 24/0
\n
"
);
printf
(
" 2 - TBI 0/24
\n
"
);
printf
(
" 2 - TBI 0/24
\n
"
);
...
@@ -123,6 +128,7 @@ int main(int argc, char* argv[])
...
@@ -123,6 +128,7 @@ int main(int argc, char* argv[])
cmd
=
cmdAWrite
;
cmd
=
cmdAWrite
;
if
(
optind
<
argc
&&
(
argv
[
optind
])[
0
]
!=
'-'
)
if
(
optind
<
argc
&&
(
argv
[
optind
])[
0
]
!=
'-'
)
val
=
atoi
(
argv
[
optind
]);
val
=
atoi
(
argv
[
optind
]);
break
;
break
;
case
'd'
:
case
'd'
:
...
@@ -146,8 +152,17 @@ int main(int argc, char* argv[])
...
@@ -146,8 +152,17 @@ int main(int argc, char* argv[])
break
;
break
;
case
'c'
:
case
'c'
:
{
cmd
=
cmdConfig
;
cmd
=
cmdConfig
;
val
=
atoi
(
optarg
);
chan
[
cnum
++
]
=
atoi
(
optarg
);
if
(
optind
<
argc
&&
(
argv
[
optind
])[
0
]
!=
'-'
)
val
=
atoi
(
argv
[
optind
]);
else
{
fprintf
(
stderr
,
"(config error: Unkown channel type. Use '-c chan type'
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
break
;
break
;
case
'q'
:
case
'q'
:
...
@@ -300,19 +315,23 @@ int main(int argc, char* argv[])
...
@@ -300,19 +315,23 @@ int main(int argc, char* argv[])
{
{
for
(
int
k
=
0
;
chan
[
k
]
!=-
1
;
k
++
)
for
(
int
k
=
0
;
chan
[
k
]
!=-
1
;
k
++
)
{
{
if
(
val
!=
INSN_CONFIG_DIO_INPUT
if
(
val
!=
INSN_CONFIG_DIO_INPUT
&&
val
!=
INSN_CONFIG_DIO_OUTPUT
&&
val
!=
INSN_CONFIG_DIO_OUTPUT
&&
val
!=
100
/* INSN_CONFIG_AIO_INPUT */
&&
val
!=
100
/* INSN_CONFIG_AIO_INPUT */
&&
val
!=
101
/* INSN_CONFIG_AIO_OUTPUT */
&&
val
!=
101
/* INSN_CONFIG_AIO_OUTPUT */
&&
val
!=
200
/* INSN_CONFIG_AIO_INPUT */
&&
val
!=
201
/* INSN_CONFIG_AIO_OUTPUT */
)
)
{
{
fprintf
(
stderr
,
"can't config channel %d for type = %d (val=[
%d,%d,%d,%d])
\n
"
fprintf
(
stderr
,
"Configure channel %d type error type='%d'. Type must be [%d,%d,
%d,%d,%d,%d])
\n
"
,
chan
[
k
],
val
,
INSN_CONFIG_DIO_INPUT
,
INSN_CONFIG_DIO_OUTPUT
,
100
,
101
);
,
chan
[
k
],
val
,
INSN_CONFIG_DIO_INPUT
,
INSN_CONFIG_DIO_OUTPUT
,
100
,
101
,
200
,
201
);
exret
=
EXIT_FAILURE
;
exret
=
EXIT_FAILURE
;
}
}
else
insn_config
(
card
,
subdev
,
chan
[
k
],
val
,
range
,
aref
);
}
}
}
}
break
;
case
cmdSubConfig
:
case
cmdSubConfig
:
insn_subdev_config
(
card
,
subdev
,
val
);
insn_subdev_config
(
card
,
subdev
,
val
);
...
@@ -329,16 +348,21 @@ int main(int argc, char* argv[])
...
@@ -329,16 +348,21 @@ int main(int argc, char* argv[])
void
insn_config
(
comedi_t
*
card
,
int
subdev
,
int
channel
,
lsampl_t
iotype
,
int
range
,
int
aref
)
void
insn_config
(
comedi_t
*
card
,
int
subdev
,
int
channel
,
lsampl_t
iotype
,
int
range
,
int
aref
)
{
{
lsampl_t
data
[
2
];
comedi_insn
insn
;
comedi_insn
insn
;
memset
(
&
insn
,
0
,
sizeof
(
insn
));
memset
(
&
insn
,
0
,
sizeof
(
insn
));
insn
.
insn
=
INSN_CONFIG
;
insn
.
insn
=
INSN_CONFIG
;
insn
.
n
=
1
;
insn
.
n
=
2
;
insn
.
data
=
&
iotype
;
insn
.
data
=
data
;
insn
.
subdev
=
subdev
;
insn
.
subdev
=
subdev
;
insn
.
chanspec
=
CR_PACK
(
channel
,
range
,
aref
);
insn
.
chanspec
=
CR_PACK
(
channel
,
0
,
0
);
// range,aref);
data
[
0
]
=
iotype
;
data
[
1
]
=
iotype
;
if
(
comedi_do_insn
(
card
,
&
insn
)
<
0
)
if
(
comedi_do_insn
(
card
,
&
insn
)
<
0
)
{
{
fprintf
(
stderr
,
"
can`t configure (AIO) subdev=%d channel=%d type=%d"
,
subdev
,
channel
,
iotype
);
fprintf
(
stderr
,
"
(insn_config): can`t configure (AIO) subdev=%d channel=%d type=%d. Err(%d): %s
\n
"
,
subdev
,
channel
,
iotype
,
errno
,
strerror
(
errno
)
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
}
...
@@ -378,7 +402,7 @@ void insn_subdev_config( comedi_t* card, int subdev, lsampl_t type )
...
@@ -378,7 +402,7 @@ void insn_subdev_config( comedi_t* card, int subdev, lsampl_t type )
if
(
comedi_do_insn
(
card
,
&
insn
)
<
0
)
if
(
comedi_do_insn
(
card
,
&
insn
)
<
0
)
{
{
fprintf
(
stderr
,
"can`t configure subdev subdev=%d type=%d. Err(%d): %s
\n
"
,
subdev
,
type
,
errno
,
strerror
(
errno
));
fprintf
(
stderr
,
"
(insn_subdev_config):
can`t configure subdev subdev=%d type=%d. Err(%d): %s
\n
"
,
subdev
,
type
,
errno
,
strerror
(
errno
));
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
}
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