Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
osie
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
Nikola Balog
osie
Commits
84653282
Commit
84653282
authored
Feb 28, 2023
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tsn evaluation
parent
d4237734
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
1 deletion
+68
-1
coupler/cli.h
coupler/cli.h
+6
-0
coupler/keep_alive.h
coupler/keep_alive.h
+6
-0
coupler/keep_alive_subscriber.h
coupler/keep_alive_subscriber.h
+56
-1
No files found.
coupler/cli.h
View file @
84653282
...
@@ -196,5 +196,11 @@ void handleCLI(int argc, char **argv) {
...
@@ -196,5 +196,11 @@ void handleCLI(int argc, char **argv) {
}
}
printf
(
"Heart beat check=%d
\n
"
,
ENABLE_HEART_BEAT_CHECK
);
printf
(
"Heart beat check=%d
\n
"
,
ENABLE_HEART_BEAT_CHECK
);
// update current measurement mode
const
char
*
s
=
getenv
(
"CURRENT_GPIO_MODE"
);
if
(
s
!=
NULL
)
CURRENT_GPIO_MODE
=
1
;
printf
(
"GPIO measurement mode = %d
\n
"
,
CURRENT_GPIO_MODE
);
}
}
coupler/keep_alive.h
View file @
84653282
...
@@ -17,6 +17,12 @@ const int STATE_NO_INITIAL_HEART_BEAT = 2;
...
@@ -17,6 +17,12 @@ const int STATE_NO_INITIAL_HEART_BEAT = 2;
// number of times the coupler was in SAFE mode
// number of times the coupler was in SAFE mode
static
unsigned
int
SAFE_MODE_STATE_COUNTER
=
0
;
static
unsigned
int
SAFE_MODE_STATE_COUNTER
=
0
;
// the current GPI state (used for debuging)
static
unsigned
int
CURRENT_GPIO_STATE
=
0
;
// variable representing the measurement over GPIO
static
unsigned
int
CURRENT_GPIO_MODE
=
0
;
// the heart beat interval (in ms)
// the heart beat interval (in ms)
const
int
DEFAULT_HEART_BEAT_INTERVAL
=
250
;
const
int
DEFAULT_HEART_BEAT_INTERVAL
=
250
;
static
int
HEART_BEAT_INTERVAL
=
DEFAULT_HEART_BEAT_INTERVAL
;
static
int
HEART_BEAT_INTERVAL
=
DEFAULT_HEART_BEAT_INTERVAL
;
...
...
coupler/keep_alive_subscriber.h
View file @
84653282
...
@@ -8,15 +8,65 @@
...
@@ -8,15 +8,65 @@
#include <stdio.h>
#include <stdio.h>
#include <signal.h>
#include <signal.h>
#include <stdlib.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/gpio.h>
UA_NodeId
connectionIdentifier
;
UA_NodeId
connectionIdentifier
;
UA_NodeId
readerGroupIdentifier
;
UA_NodeId
readerGroupIdentifier
;
UA_NodeId
readerIdentifier
;
UA_NodeId
readerIdentifier
;
UA_DataSetReaderConfig
readerConfig
;
UA_DataSetReaderConfig
readerConfig
;
static
void
fillTestDataSetMetaData
(
UA_DataSetMetaDataType
*
pMetaData
);
static
void
fillTestDataSetMetaData
(
UA_DataSetMetaDataType
*
pMetaData
);
static
int
setGPIO
()
{
/*
* Set GPIO state (useful for debuging with logical analyzer
*/
int
fd
;
struct
gpiohandle_request
led
;
struct
gpiohandle_data
data
;
/* Schema for STMP15x-Shield
* GND : pin 2
* Channel 0 : pin 9
*/
fd
=
open
(
"/dev/gpiochip1"
,
O_RDWR
);
if
(
fd
<
0
)
{
perror
(
"Error opening gpiochip"
);
return
-
1
;
}
/* Setup GPIO to output */
led
.
flags
=
GPIOHANDLE_REQUEST_OUTPUT
;
strcpy
(
led
.
consumer_label
,
"LED"
);
memset
(
led
.
default_values
,
0
,
sizeof
(
led
.
default_values
));
led
.
lines
=
1
;
led
.
lineoffsets
[
0
]
=
7
;
if
(
ioctl
(
fd
,
GPIO_GET_LINEHANDLE_IOCTL
,
&
led
)
<
0
)
{
perror
(
"Error setting GPIO to output"
);
close
(
fd
);
return
-
1
;
}
// revert previous state
if
(
CURRENT_GPIO_STATE
)
CURRENT_GPIO_STATE
=
0
;
else
CURRENT_GPIO_STATE
=
1
;
if
(
ioctl
(
led
.
fd
,
GPIOHANDLE_SET_LINE_VALUES_IOCTL
,
&
data
)
<
0
)
perror
(
"Error setting GPIO to 1"
);
// debug
//UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, \
// "GPIO = %d", CURRENT_GPIO_STATE);
close
(
fd
);
close
(
led
.
fd
);
return
0
;
}
/* callback to handle change notifications */
/* callback to handle change notifications */
static
void
dataChangeNotificationCallback
(
UA_Server
*
server
,
UA_UInt32
monitoredItemId
,
static
void
dataChangeNotificationCallback
(
UA_Server
*
server
,
UA_UInt32
monitoredItemId
,
...
@@ -45,6 +95,11 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
...
@@ -45,6 +95,11 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
// Add to our local linked list
// Add to our local linked list
addItem
(
&
SUBSCRIBER_DICT
,
coupler_id_str
,
milli_seconds_now_str
);
addItem
(
&
SUBSCRIBER_DICT
,
coupler_id_str
,
milli_seconds_now_str
);
// set GPIO so we can monitor using logical analyzer the work of
// keep-alive network system
if
(
CURRENT_GPIO_MODE
)
setGPIO
();
}
}
}
}
}
}
...
...
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