BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mangoh-drivers
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
mangoh-drivers
Commits
e5b44666
Unverified
Commit
e5b44666
authored
Apr 05, 2019
by
ashsyal
Committed by
GitHub
Apr 05, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #27 from dpfrey/simplified_yellow_actuators
simplify implementation of YellowOnBoardActuators
parents
8077ab3d
2f05e797
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
174 additions
and
654 deletions
+174
-654
actuator.adef
apps/YellowOnBoardActuators/actuator.adef
+3
-12
generic_led.c
...llowOnBoardActuators/components/led/generic/generic_led.c
+0
-129
tri_led_blu.c
...llowOnBoardActuators/components/led/triBlue/tri_led_blu.c
+0
-140
Component.cdef
...owOnBoardActuators/components/led/triGreen/Component.cdef
+0
-31
tri_led_green.c
...wOnBoardActuators/components/led/triGreen/tri_led_green.c
+0
-140
Component.cdef
...llowOnBoardActuators/components/led/triRed/Component.cdef
+0
-31
tri_led_red.c
...ellowOnBoardActuators/components/led/triRed/tri_led_red.c
+0
-140
Component.cdef
...OnBoardActuators/components/outputActuator/Component.cdef
+10
-16
outputActuator.c
...BoardActuators/components/outputActuator/outputActuator.c
+103
-0
outputActuator.h
...BoardActuators/components/outputActuator/outputActuator.h
+6
-0
Component.cdef
...nBoardActuators/components/yellowActuators/Component.cdef
+10
-15
yellowActuators.c
...ardActuators/components/yellowActuators/yellowActuators.c
+42
-0
No files found.
apps/YellowOnBoardActuators/actuator.adef
View file @
e5b44666
...
...
@@ -4,19 +4,14 @@ version: 0.1
executables:
{
actuatorYellow = (
components/led/generic
components/led/triRed
components/led/triGreen
components/led/triBlue
)
actuatorYellow = ( components/yellowActuators )
}
processes:
{
run:
{
( actuatorYellow
)
( actuatorYellow )
}
envVars:
...
...
@@ -26,11 +21,7 @@ processes:
faultAction: stopApp
}
bindings:
{
actuatorYellow.generic.dhubIO -> dataHub.io
actuatorYellow.triRed.dhubIO -> dataHub.io
actuatorYellow.triGreen.dhubIO -> dataHub.io
actuatorYellow.triBlue.dhubIO -> dataHub.io
actuatorYellow.outputActuator.dhub -> dataHub.io
}
apps/YellowOnBoardActuators/components/led/generic/generic_led.c
deleted
100644 → 0
View file @
8077ab3d
/**
*
* This file provides the implementation of @ref c_led
*
*
* <hr>
*
* Copyright (C) Sierra Wireless Inc.
*/
#include "legato.h"
#include "interfaces.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(array) ((unsigned long) (sizeof (array) / sizeof ((array)[0])))
#endif
#define RES_PATH_GENERIC_LED "generic_led"
#define RES_PATH_GENERIC_VALUE "generic_led/value"
static
const
char
GenericLedPath
[]
=
"/sys/devices/platform/expander.0/generic_led"
;
typedef
struct
{
const
char
*
path
;
dhubIO_DataType_t
dataType
;
const
char
*
units
;
dhubIO_BooleanPushHandlerRef_t
ref
;
}
actuator_DhOut_t
;
static
actuator_DhOut_t
dhubResources
[]
=
{
{
RES_PATH_GENERIC_LED
,
DHUBIO_DATA_TYPE_BOOLEAN
,
""
,
NULL
},
};
static
void
actuator_DhOutputHandler
(
double
timestamp
,
bool
value
,
void
*
context
)
{
const
char
*
writeData
=
value
?
"1"
:
"0"
;
FILE
*
ledFile
=
fopen
(
GenericLedPath
,
"r+"
);
if
(
ledFile
==
NULL
)
{
LE_ERROR
(
"Open LED device file('%s') failed(%d)"
,
GenericLedPath
,
errno
);
return
;
}
LE_DEBUG
(
"Turn %s LED"
,
value
?
"on"
:
"off"
);
if
(
fwrite
(
writeData
,
sizeof
(
writeData
),
1
,
ledFile
)
!=
1
)
{
LE_ERROR
(
"Write LED device file('%s') failed"
,
GenericLedPath
);
}
dhubIO_PushBoolean
(
RES_PATH_GENERIC_VALUE
,
DHUBIO_NOW
,
value
);
dhubIO_MarkOptional
(
RES_PATH_GENERIC_LED
);
fclose
(
ledFile
);
}
static
le_result_t
actuator_DhRegister
(
void
)
{
le_result_t
result
=
LE_OK
;
for
(
int
i
=
0
;
i
<
ARRAY_SIZE
(
dhubResources
);
i
++
)
{
result
=
dhubIO_CreateOutput
(
dhubResources
[
i
].
path
,
dhubResources
[
i
].
dataType
,
dhubResources
[
i
].
units
);
if
(
LE_OK
!=
result
)
{
LE_ERROR
(
"Failed to create output resource %s"
,
dhubResources
[
i
].
path
);
break
;
}
LE_ASSERT
(
LE_OK
==
dhubIO_CreateInput
(
RES_PATH_GENERIC_VALUE
,
DHUBIO_DATA_TYPE_BOOLEAN
,
""
));
dhubResources
[
i
].
ref
=
dhubIO_AddBooleanPushHandler
(
dhubResources
[
i
].
path
,
actuator_DhOutputHandler
,
NULL
);
if
(
NULL
==
dhubResources
[
i
].
ref
)
{
LE_ERROR
(
"Failed to add handler for output resource %s"
,
dhubResources
[
i
].
path
);
result
=
LE_FAULT
;
break
;
}
}
return
result
;
}
//--------------------------------------------------------------------------------------------------
/**
* SIGTERM handler to cleanly shutdown
*/
//--------------------------------------------------------------------------------------------------
static
void
actuator_SigTermHandler
(
int
pSigNum
)
{
(
void
)
pSigNum
;
LE_INFO
(
"Remove LED resource"
);
dhubIO_DeleteResource
(
GenericLedPath
);
}
//--------------------------------------------------------------------------------------------------
/**
* Main program
*/
//--------------------------------------------------------------------------------------------------
COMPONENT_INIT
{
///< Catch application termination and shutdown cleanly
le_sig_Block
(
SIGTERM
);
le_sig_SetEventHandler
(
SIGTERM
,
actuator_SigTermHandler
);
LE_ASSERT
(
LE_OK
==
actuator_DhRegister
());
}
apps/YellowOnBoardActuators/components/led/triBlue/tri_led_blu.c
deleted
100644 → 0
View file @
8077ab3d
/**
*
* This file provides the implementation of @ref c_led
*
*
* <hr>
*
* Copyright (C) Sierra Wireless Inc.
*/
#include "legato.h"
#include "interfaces.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(array) ((unsigned long) (sizeof (array) / sizeof ((array)[0])))
#endif
#define RES_PATH_TRI_BLUE_LED "tri_led_blue"
#define RES_PATH_BLUE_VALUE "tri_led_blue/value"
static
const
char
TriBlueLedPath
[]
=
"/sys/devices/platform/expander.0/tri_led_blu"
;
typedef
struct
{
const
char
*
path
;
dhubIO_DataType_t
dataType
;
const
char
*
units
;
dhubIO_BooleanPushHandlerRef_t
ref
;
}
actuator_DhOut_t
;
static
actuator_DhOut_t
dhubResources
[]
=
{
{
RES_PATH_TRI_BLUE_LED
,
DHUBIO_DATA_TYPE_BOOLEAN
,
""
,
NULL
},
};
static
void
actuator_DhOutputHandler
(
double
timestamp
,
bool
value
,
void
*
context
)
{
const
char
*
writeData
=
value
?
"1"
:
"0"
;
FILE
*
ledFile
=
fopen
(
TriBlueLedPath
,
"r+"
);
if
(
ledFile
==
NULL
)
{
LE_ERROR
(
"Open LED device file('%s') failed(%d)"
,
TriBlueLedPath
,
errno
);
return
;
}
LE_DEBUG
(
"Turn %s LED"
,
value
?
"on"
:
"off"
);
if
(
fwrite
(
writeData
,
sizeof
(
writeData
),
1
,
ledFile
)
!=
1
)
{
LE_ERROR
(
"Write LED device file('%s') failed"
,
TriBlueLedPath
);
}
dhubIO_PushBoolean
(
RES_PATH_BLUE_VALUE
,
DHUBIO_NOW
,
value
);
dhubIO_MarkOptional
(
RES_PATH_TRI_BLUE_LED
);
dhubIO_SetBooleanDefault
(
RES_PATH_TRI_BLUE_LED
,
false
);
fclose
(
ledFile
);
}
static
le_result_t
actuator_DhRegister
(
void
)
{
le_result_t
result
=
LE_OK
;
for
(
int
i
=
0
;
i
<
ARRAY_SIZE
(
dhubResources
);
i
++
)
{
result
=
dhubIO_CreateOutput
(
dhubResources
[
i
].
path
,
dhubResources
[
i
].
dataType
,
dhubResources
[
i
].
units
);
if
(
LE_OK
!=
result
)
{
LE_ERROR
(
"Failed to create output resource %s"
,
dhubResources
[
i
].
path
);
break
;
}
/* LE_ASSERT(LE_OK == dhubIO_CreateInput(dhubResources[i].value, DHUBIO_DATA_TYPE_BOOLEAN, ""));
dhubResources[i].ref = dhubIO_AddBooleanPushHandler(dhubResources[i].path,
actuator_DhOutputHandler,
(void *) &dhubResources[i].gpio_path);
*/
LE_ASSERT
(
LE_OK
==
dhubIO_CreateInput
(
RES_PATH_BLUE_VALUE
,
DHUBIO_DATA_TYPE_BOOLEAN
,
""
));
dhubResources
[
i
].
ref
=
dhubIO_AddBooleanPushHandler
(
dhubResources
[
i
].
path
,
actuator_DhOutputHandler
,
NULL
);
if
(
NULL
==
dhubResources
[
i
].
ref
)
{
LE_ERROR
(
"Failed to add handler for output resource %s"
,
dhubResources
[
i
].
path
);
result
=
LE_FAULT
;
break
;
}
}
return
result
;
}
//--------------------------------------------------------------------------------------------------
/**
* SIGTERM handler to cleanly shutdown
*/
//--------------------------------------------------------------------------------------------------
static
void
actuator_SigTermHandler
(
int
pSigNum
)
{
(
void
)
pSigNum
;
LE_INFO
(
"Remove LED resource"
);
dhubIO_DeleteResource
(
TriBlueLedPath
);
}
//--------------------------------------------------------------------------------------------------
/**
* Main program
*/
//--------------------------------------------------------------------------------------------------
COMPONENT_INIT
{
///< Catch application termination and shutdown cleanly
le_sig_Block
(
SIGTERM
);
le_sig_SetEventHandler
(
SIGTERM
,
actuator_SigTermHandler
);
LE_ASSERT
(
LE_OK
==
actuator_DhRegister
());
}
apps/YellowOnBoardActuators/components/led/triGreen/Component.cdef
deleted
100644 → 0
View file @
8077ab3d
//--------------------------------------------------------------------------------------------------
/**
* Component definition file for the mangOH Yellow on board actuator component.
*/
//--------------------------------------------------------------------------------------------------
cflags:
{
-std=c99
-DMANGOH_BOARD=YELLOW
}
requires:
{
api:
{
dhubIO = io.api
}
file:
{
/sys/devices/platform/expander.0/tri_led_grn /sys/devices/platform/expander.0/tri_led_grn
}
}
sources:
{
tri_led_green.c
}
apps/YellowOnBoardActuators/components/led/triGreen/tri_led_green.c
deleted
100644 → 0
View file @
8077ab3d
/**
*
* This file provides the implementation of @ref c_led
*
*
* <hr>
*
* Copyright (C) Sierra Wireless Inc.
*/
#include "legato.h"
#include "interfaces.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(array) ((unsigned long) (sizeof (array) / sizeof ((array)[0])))
#endif
#define RES_PATH_TRI_GREEN_LED "tri_led_green"
#define RES_PATH_GREEN_VALUE "tri_led_green/value"
static
const
char
TriGreenLedPath
[]
=
"/sys/devices/platform/expander.0/tri_led_grn"
;
typedef
struct
{
const
char
*
path
;
dhubIO_DataType_t
dataType
;
const
char
*
units
;
dhubIO_BooleanPushHandlerRef_t
ref
;
}
actuator_DhOut_t
;
static
actuator_DhOut_t
dhubResources
[]
=
{
{
RES_PATH_TRI_GREEN_LED
,
DHUBIO_DATA_TYPE_BOOLEAN
,
""
,
NULL
},
};
static
void
actuator_DhOutputHandler
(
double
timestamp
,
bool
value
,
void
*
context
)
{
const
char
*
writeData
=
value
?
"1"
:
"0"
;
FILE
*
ledFile
=
fopen
(
TriGreenLedPath
,
"r+"
);
if
(
ledFile
==
NULL
)
{
LE_ERROR
(
"Open LED device file('%s') failed(%d)"
,
TriGreenLedPath
,
errno
);
return
;
}
LE_DEBUG
(
"Turn %s LED"
,
value
?
"on"
:
"off"
);
if
(
fwrite
(
writeData
,
sizeof
(
writeData
),
1
,
ledFile
)
!=
1
)
{
LE_ERROR
(
"Write LED device file('%s') failed"
,
TriGreenLedPath
);
}
dhubIO_PushBoolean
(
RES_PATH_GREEN_VALUE
,
DHUBIO_NOW
,
value
);
dhubIO_MarkOptional
(
RES_PATH_TRI_GREEN_LED
);
dhubIO_SetBooleanDefault
(
RES_PATH_TRI_GREEN_LED
,
false
);
fclose
(
ledFile
);
}
static
le_result_t
actuator_DhRegister
(
void
)
{
le_result_t
result
=
LE_OK
;
for
(
int
i
=
0
;
i
<
ARRAY_SIZE
(
dhubResources
);
i
++
)
{
result
=
dhubIO_CreateOutput
(
dhubResources
[
i
].
path
,
dhubResources
[
i
].
dataType
,
dhubResources
[
i
].
units
);
if
(
LE_OK
!=
result
)
{
LE_ERROR
(
"Failed to create output resource %s"
,
dhubResources
[
i
].
path
);
break
;
}
/* LE_ASSERT(LE_OK == dhubIO_CreateInput(dhubResources[i].value, DHUBIO_DATA_TYPE_BOOLEAN, ""));
dhubResources[i].ref = dhubIO_AddBooleanPushHandler(dhubResources[i].path,
actuator_DhOutputHandler,
(void *) &dhubResources[i].gpio_path);
*/
LE_ASSERT
(
LE_OK
==
dhubIO_CreateInput
(
RES_PATH_GREEN_VALUE
,
DHUBIO_DATA_TYPE_BOOLEAN
,
""
));
dhubResources
[
i
].
ref
=
dhubIO_AddBooleanPushHandler
(
dhubResources
[
i
].
path
,
actuator_DhOutputHandler
,
NULL
);
if
(
NULL
==
dhubResources
[
i
].
ref
)
{
LE_ERROR
(
"Failed to add handler for output resource %s"
,
dhubResources
[
i
].
path
);
result
=
LE_FAULT
;
break
;
}
}
return
result
;
}
//--------------------------------------------------------------------------------------------------
/**
* SIGTERM handler to cleanly shutdown
*/
//--------------------------------------------------------------------------------------------------
static
void
actuator_SigTermHandler
(
int
pSigNum
)
{
(
void
)
pSigNum
;
LE_INFO
(
"Remove LED resource"
);
dhubIO_DeleteResource
(
TriGreenLedPath
);
}
//--------------------------------------------------------------------------------------------------
/**
* Main program
*/
//--------------------------------------------------------------------------------------------------
COMPONENT_INIT
{
///< Catch application termination and shutdown cleanly
le_sig_Block
(
SIGTERM
);
le_sig_SetEventHandler
(
SIGTERM
,
actuator_SigTermHandler
);
LE_ASSERT
(
LE_OK
==
actuator_DhRegister
());
}
apps/YellowOnBoardActuators/components/led/triRed/Component.cdef
deleted
100644 → 0
View file @
8077ab3d
//--------------------------------------------------------------------------------------------------
/**
* Component definition file for the mangOH Yellow on board actuator component.
*/
//--------------------------------------------------------------------------------------------------
cflags:
{
-std=c99
-DMANGOH_BOARD=YELLOW
}
requires:
{
api:
{
dhubIO = io.api
}
file:
{
/sys/devices/platform/expander.0/tri_led_red /sys/devices/platform/expander.0/tri_led_red
}
}
sources:
{
tri_led_red.c
}
apps/YellowOnBoardActuators/components/led/triRed/tri_led_red.c
deleted
100644 → 0
View file @
8077ab3d
/**
*
* This file provides the implementation of @ref c_led
*
*
* <hr>
*
* Copyright (C) Sierra Wireless Inc.
*/
#include "legato.h"
#include "interfaces.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(array) ((unsigned long) (sizeof (array) / sizeof ((array)[0])))
#endif
#define RES_PATH_TRI_RED_LED "tri_led_red"
#define RES_PATH_RED_VALUE "tri_led_red/value"
static
const
char
TriRedLedPath
[]
=
"/sys/devices/platform/expander.0/tri_led_red"
;
typedef
struct
{
const
char
*
path
;
dhubIO_DataType_t
dataType
;
const
char
*
units
;
dhubIO_BooleanPushHandlerRef_t
ref
;
}
actuator_DhOut_t
;
static
actuator_DhOut_t
dhubResources
[]
=
{
{
RES_PATH_TRI_RED_LED
,
DHUBIO_DATA_TYPE_BOOLEAN
,
""
,
NULL
},
};
static
void
actuator_DhOutputHandler
(
double
timestamp
,
bool
value
,
void
*
context
)
{
const
char
*
writeData
=
value
?
"1"
:
"0"
;
FILE
*
ledFile
=
fopen
(
TriRedLedPath
,
"r+"
);
if
(
ledFile
==
NULL
)
{
LE_ERROR
(
"Open LED device file('%s') failed(%d)"
,
TriRedLedPath
,
errno
);
return
;
}
LE_DEBUG
(
"Turn %s LED"
,
value
?
"on"
:
"off"
);
if
(
fwrite
(
writeData
,
sizeof
(
writeData
),
1
,
ledFile
)
!=
1
)
{
LE_ERROR
(
"Write LED device file('%s') failed"
,
TriRedLedPath
);
}
dhubIO_PushBoolean
(
RES_PATH_RED_VALUE
,
DHUBIO_NOW
,
value
);
dhubIO_MarkOptional
(
RES_PATH_TRI_RED_LED
);
dhubIO_SetBooleanDefault
(
RES_PATH_TRI_RED_LED
,
true
);
fclose
(
ledFile
);
}
static
le_result_t
actuator_DhRegister
(
void
)
{
le_result_t
result
=
LE_OK
;
for
(
int
i
=
0
;
i
<
ARRAY_SIZE
(
dhubResources
);
i
++
)
{
result
=
dhubIO_CreateOutput
(
dhubResources
[
i
].
path
,
dhubResources
[
i
].
dataType
,
dhubResources
[
i
].
units
);
if
(
LE_OK
!=
result
)
{
LE_ERROR
(
"Failed to create output resource %s"
,
dhubResources
[
i
].
path
);
break
;
}
/* LE_ASSERT(LE_OK == dhubIO_CreateInput(dhubResources[i].value, DHUBIO_DATA_TYPE_BOOLEAN, ""));
dhubResources[i].ref = dhubIO_AddBooleanPushHandler(dhubResources[i].path,
actuator_DhOutputHandler,
(void *) &dhubResources[i].gpio_path);
*/
LE_ASSERT
(
LE_OK
==
dhubIO_CreateInput
(
RES_PATH_RED_VALUE
,
DHUBIO_DATA_TYPE_BOOLEAN
,
""
));
dhubResources
[
i
].
ref
=
dhubIO_AddBooleanPushHandler
(
dhubResources
[
i
].
path
,
actuator_DhOutputHandler
,
NULL
);
if
(
NULL
==
dhubResources
[
i
].
ref
)
{
LE_ERROR
(
"Failed to add handler for output resource %s"
,
dhubResources
[
i
].
path
);
result
=
LE_FAULT
;
break
;
}
}
return
result
;
}
//--------------------------------------------------------------------------------------------------
/**
* SIGTERM handler to cleanly shutdown
*/
//--------------------------------------------------------------------------------------------------
static
void
actuator_SigTermHandler
(
int
pSigNum
)
{
(
void
)
pSigNum
;
LE_INFO
(
"Remove LED resource"
);
dhubIO_DeleteResource
(
TriRedLedPath
);
}
//--------------------------------------------------------------------------------------------------
/**
* Main program
*/
//--------------------------------------------------------------------------------------------------
COMPONENT_INIT
{
///< Catch application termination and shutdown cleanly
le_sig_Block
(
SIGTERM
);
le_sig_SetEventHandler
(
SIGTERM
,
actuator_SigTermHandler
);
LE_ASSERT
(
LE_OK
==
actuator_DhRegister
());
}
apps/YellowOnBoardActuators/components/
led/generic
/Component.cdef
→
apps/YellowOnBoardActuators/components/
outputActuator
/Component.cdef
View file @
e5b44666
//--------------------------------------------------------------------------------------------------
/**
* Component definition file for the mangOH Yellow on board actuator component.
*/
//--------------------------------------------------------------------------------------------------
cflags:
{
-std=c99
-DMANGOH_BOARD=YELLOW
-std=c99
}
requires:
{
api:
{
dhubIO = io.api
dhub = io.api
}
}
file:
{
/sys/devices/platform/expander.0/generic_led /sys/devices/platform/expander.0/generic_led
}
provides:
{
headerDir:
{
${CURDIR}
}
}
sources:
{
generic_led
.c
outputActuator
.c
}
apps/YellowOnBoardActuators/components/outputActuator/outputActuator.c
0 → 100644
View file @
e5b44666
#include "legato.h"
#include "interfaces.h"
#include "outputActuator.h"
#define DHUB_PATH_LENGTH 256
#define SYSFS_PATH_LENGTH 256
struct
OutputActuator
{
char
dhubOutputPath
[
DHUB_PATH_LENGTH
];
char
sysfsPath
[
SYSFS_PATH_LENGTH
];
dhub_BooleanPushHandlerRef_t
pushHandlerRef
;
};
static
le_result_t
WriteStringToFile
(
const
char
*
path
,
const
char
*
s
)
{
le_result_t
res
=
LE_OK
;
const
size_t
sLen
=
strlen
(
s
);
FILE
*
f
=
fopen
(
path
,
"r+"
);
if
(
!
f
)
{
LE_ERROR
(
"Couldn't open %s: %s"
,
path
,
strerror
(
errno
));
res
=
LE_FAULT
;
goto
done
;
}
if
(
fwrite
(
s
,
1
,
sLen
,
f
)
!=
sLen
)
{
LE_ERROR
(
"Write to %s failed"
,
path
);
res
=
LE_IO_ERROR
;
goto
cleanup
;
}
cleanup:
fclose
(
f
);
done:
return
res
;
}
static
void
ActuatorPushHandler
(
double
timestamp
,
bool
value
,
void
*
context
)
{
struct
OutputActuator
*
oa
=
context
;
le_result_t
res
=
WriteStringToFile
(
oa
->
sysfsPath
,
value
?
"1"
:
"0"
);
if
(
res
!=
LE_OK
)
{
return
;
}
}
le_result_t
RegisterOutputActuator
(
const
char
*
dhubBasePath
,
const
char
*
sysfsPath
)
{
/*
* TODO: The current design assumes that once an actuator has been registered, it can't be
* deregistered so I make no attempt to hang onto the pointer so that it can be cleaned up
* later.
*/
struct
OutputActuator
*
oa
=
calloc
(
sizeof
(
*
oa
),
1
);
LE_ASSERT
(
oa
);
le_result_t
res
=
LE_OK
;
strncpy
(
oa
->
sysfsPath
,
sysfsPath
,
SYSFS_PATH_LENGTH
);
LE_FATAL_IF
(
oa
->
sysfsPath
[
SYSFS_PATH_LENGTH
-
1
]
!=
'\0'
,
"path too long"
);
int
snprintfRes
=
snprintf
(
oa
->
dhubOutputPath
,
sizeof
(
oa
->
dhubOutputPath
),
"%s/%s"
,
dhubBasePath
,
"value"
);
if
(
snprintfRes
<
0
)
{
LE_ERROR
(
"Failed to format output path"
);
res
=
LE_FAULT
;
goto
error_output
;
}
else
if
(
snprintfRes
>=
sizeof
(
oa
->
dhubOutputPath
))
{
res
=
LE_OVERFLOW
;
goto
error_output
;
}
const
char
*
noUnits
=
""
;
res
=
dhub_CreateOutput
(
oa
->
dhubOutputPath
,
DHUB_DATA_TYPE_BOOLEAN
,
noUnits
);
if
(
res
!=
LE_OK
)
{
LE_ERROR
(
"Failed to create DataHub output %s"
,
oa
->
dhubOutputPath
);
goto
error_output
;
}
dhub_SetBooleanDefault
(
oa
->
dhubOutputPath
,
false
);
oa
->
pushHandlerRef
=
dhub_AddBooleanPushHandler
(
oa
->
dhubOutputPath
,
ActuatorPushHandler
,
oa
);
return
res
;
error_output:
free
(
oa
);
return
res
;
}
COMPONENT_INIT
{
}
apps/YellowOnBoardActuators/components/outputActuator/outputActuator.h
0 → 100644
View file @
e5b44666
#ifndef _OUTPUT_ACTUATOR_H_
#define _OUTPUT_ACTUATOR_H_
LE_SHARED
le_result_t
RegisterOutputActuator
(
const
char
*
dhubBasePath
,
const
char
*
sysfsPath
);
#endif // _OUTPUT_ACTUATOR_H_
apps/YellowOnBoardActuators/components/
led/triBlue
/Component.cdef
→
apps/YellowOnBoardActuators/components/
yellowActuators
/Component.cdef
View file @
e5b44666
//--------------------------------------------------------------------------------------------------
/**
* Component definition file for the mangOH Yellow on board actuator component.
*/
//--------------------------------------------------------------------------------------------------
cflags:
{
-std=c99
-DMANGOH_BOARD=YELLOW
-std=c99
}
requires:
{
api
:
component
:
{
dhubIO = io.api
../outputActuator
}
file:
{
/sys/devices/platform/expander.0/tri_led_blu /sys/devices/platform/expander.0/tri_led_blu
}
{
/sys/devices/platform/expander.0/generic_led /sys/devices/platform/expander.0/
/sys/devices/platform/expander.0/tri_led_red /sys/devices/platform/expander.0/
/sys/devices/platform/expander.0/tri_led_grn /sys/devices/platform/expander.0/
/sys/devices/platform/expander.0/tri_led_blu /sys/devices/platform/expander.0/
}
}
sources:
{
tri_led_blu
.c
yellowActuators
.c
}
apps/YellowOnBoardActuators/components/yellowActuators/yellowActuators.c
0 → 100644
View file @
e5b44666
#include "legato.h"
#include "interfaces.h"
#include "outputActuator.h"
static
const
struct
{
const
char
*
sysfsPath
;
const
char
*
dhubPath
;
}
OutputActuators
[]
=
{
{
.
sysfsPath
=
"/sys/devices/platform/expander.0/tri_led_red"
,
.
dhubPath
=
"tri_led_red"
,
},
{
.
sysfsPath
=
"/sys/devices/platform/expander.0/tri_led_grn"
,
.
dhubPath
=
"tri_led_green"
,
},
{
.
sysfsPath
=
"/sys/devices/platform/expander.0/tri_led_blu"
,
.
dhubPath
=
"tri_led_blue"
,
},
{
.
sysfsPath
=
"/sys/devices/platform/expander.0/generic_led"
,
.
dhubPath
=
"generic_led"
,
},
};
COMPONENT_INIT
{
for
(
int
i
=
0
;
i
<
NUM_ARRAY_MEMBERS
(
OutputActuators
);
i
++
)
{
le_result_t
res
=
RegisterOutputActuator
(
OutputActuators
[
i
].
dhubPath
,
OutputActuators
[
i
].
sysfsPath
);
LE_FATAL_IF
(
res
!=
LE_OK
,
"Output actuator registration failed for %s at %s"
,
OutputActuators
[
i
].
sysfsPath
,
OutputActuators
[
i
].
dhubPath
);
}
}
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