Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100700520
simple.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 2, 00:22
Size
1 KB
Mime Type
text/x-c
Expires
Tue, Feb 4, 00:22 (2 d)
Engine
blob
Format
Raw Data
Handle
24016828
Attached To
R6621 SBCP High-Level Driver
simple.cpp
View Options
/**
* \file simple.cpp
*
* \date May 4, 2012
* \author Alexandre Tuleu
*/
#include <iostream>
#include <stdexcept>
#include <libsbcp/bus/Bus.h>
#include <libsbcp/devices/motordriver_board/MotorDriver.h>
#include <sbcpd/si/ft2232h.h>
using
namespace
sbcp
;
using
namespace
sbcp
::
amarsi
;
int
main
(){
sbcpd_bus_settings
*
s
=
sbcpd_bus_settings_create
();
//lowest requirement
sbcpd_bus_settings_set_required_frame_definition
(
s
,
1
,
0
);
sbcpd_serial_interface
*
si
=
sbcpd_ft2232h_create_interface
();
if
(
sbcpd_ft2232h_open
(
si
,
3310000
,
1
,
2
)
!=
SBCPD_NO_ERROR
){
throw
std
::
runtime_error
(
std
::
string
(
"could not open serial interface : "
)
+
si
->
error
.
msg
);
}
Bus
d_bus
(
s
,
si
);
// !warning this will perform an heavy IO operation !
MotorDriver
::
Ptr
mv
=
d_bus
.
OpenDevice
<
MotorDriver
>
(
0x01
);
if
(
!
mv
||
!
mv
.
get
()){
throw
std
::
runtime_error
(
"could not open Motordriver 0x01"
);
}
// !warning this will perform an heavy IO operation !
std
::
cout
<<
"First motor has position : "
<<
mv
->
Motor1
().
PresentPosition
().
Get
()
<<
std
::
endl
;
return
0
;
}
Event Timeline
Log In to Comment