n_frames_single_shot_example.c
Go to the documentation of this file.
1 
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include "example_common.h"
11 #include "toposens/sensor_lib.h"
12 
13 static void LogMsgCallback(uint16_t SenderId_u16, uint8_t* ReceivedPayload_pu8);
14 
15 static void SingleShotMeasurement()
16 {
18  uint16_t current_sensing_sensor = WaitForSessionStart();
19  uint16_t sender = WaitForSessionEnd();
20  Sensor_Session_t* session_data = GetSessionData(sender);
21  PrintSessionData(session_data);
22 }
23 
24 int main(int argc, char** argv)
25 {
26  int num_of_frames = 0;
27  int c;
28 
29  if (argc < 2)
30  {
31  fprintf(stderr, "Pass -n argument.\n");
32  return -1;
33  }
34 
35  while ((c = getopt(argc, argv, "n:")) != -1) switch (c)
36  {
37  case 'n':
38  num_of_frames = atoi(optarg);
39  if (num_of_frames < 0) num_of_frames = 0;
40  break;
41  case '?':
42  if (optopt == 'n')
43  fprintf(stderr, "Option -%c requires an argument.\n", optopt);
44  else
45  fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
46  return 1;
47  default:;
48  }
49 
51  InitInterface("can0", 1000000, IF_CAN);
52  if (RequestReboot())
53  {
54  printf("Blocking Reboot Request worked\n");
55  }
56  else
57  {
58  printf("Blocking Reboot Request worked but did not got the right ack\n");
59  }
60  WaitForReady();
61 
63 
64  int i;
65  for (i = 0; i < num_of_frames; i++)
66  {
68  }
69 
71  return 0;
72 }
73 
74 static void LogMsgCallback(uint16_t SenderId_u16, uint8_t* ReceivedPayload_pu8)
75 {
76  PrintLogMessage(SenderId_u16, ReceivedPayload_pu8);
77 }
RequestReboot
bool RequestReboot()
Request selected sensor to reboot.
Definition: sensor_lib.c:2330
DeinitInterface
void DeinitInterface(CommsInterfaceType_t Interface_t)
Instruction to deinit the specified interface type.
Definition: sensor_lib.c:2279
WaitForSessionEnd
uint16_t WaitForSessionEnd()
Blocking Function call to wait for SessionEnd Payload.
Definition: sensor_lib.c:3370
main
int main(int argc, char **argv)
Definition: n_frames_single_shot_example.c:24
RequestMeasurement
bool RequestMeasurement()
Send's a request to start a new measurement.
Definition: sensor_lib.c:2348
WaitForReady
uint16_t WaitForReady()
Blocking Function call to wait for Ready Payload.
Definition: sensor_lib.c:3395
GetSessionData
Sensor_Session_t * GetSessionData(uint16_t Sender_u16)
Interface function to query current session-data (ongoing and closed session)
Definition: sensor_lib.c:3422
InitInterface
void InitInterface(char *InterfaceName, uint32_t DataRate_u32, CommsInterfaceType_t Interface_t)
Instruction to initialize the specified interface with the specified bit rate. Will also initialize t...
Definition: sensor_lib.c:2225
PrintSessionData
void PrintSessionData(Sensor_Session_t *Session)
Definition: example_common.c:85
SENSOR_MODE_SINGLE_SHOT_TRANSMIT_LISTEN
@ SENSOR_MODE_SINGLE_SHOT_TRANSMIT_LISTEN
Definition: custom_types.h:68
SetParameterSystemSensorMode
bool SetParameterSystemSensorMode(SensorMode_t Mode_t)
Blocking Request to set the Sensor Mode for current target sensor.
Definition: sensor_lib.c:2812
IF_CAN
@ IF_CAN
Definition: custom_types.h:13
WaitForSessionStart
uint16_t WaitForSessionStart()
Blocking Function call to wait for SessionStart Payload.
Definition: sensor_lib.c:3342
Sensor_Session_t
Definition: sensor_lib.h:61
SingleShotMeasurement
static void SingleShotMeasurement()
Definition: n_frames_single_shot_example.c:15
sensor_lib.h
This file contains the highlevel interface prototypes to the low-level Protocol.
RegisterLogMsgCallback
void RegisterLogMsgCallback(void(*Callback)(uint16_t Sender_u16, uint8_t *ReceivedPayload_pu8))
Interface function to register a callback function that is called whenever a Logmessage Payload is re...
Definition: sensor_lib.c:3409
example_common.h
Library containing common functions that are used in the various examples.
LogMsgCallback
static void LogMsgCallback(uint16_t SenderId_u16, uint8_t *ReceivedPayload_pu8)
Definition: n_frames_single_shot_example.c:74
PrintLogMessage
void PrintLogMessage(uint16_t SenderId_u16, const uint8_t *ReceivedPayload_pu8)
Definition: example_common.c:154


toposens_echo_driver
Author(s): Tobias Roth , Dennis Maier , Baris Yazici
autogenerated on Wed Mar 2 2022 01:12:32