-
Notifications
You must be signed in to change notification settings - Fork 34
/
main.c
41 lines (31 loc) · 978 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdint.h>
#include <stdio.h>
#include <serial.h>
#include <parsing.h>
int main(int argc, char** argv) {
char *port_name_1 = argv[1]; // SBUS
char *port_name_2 = argv[2]; // Sabertooth1
FILE *sbus;
FILE *sabertooth;
// to store sbus packets
uint8_t sbus_packet[15];
// to store value of indiviual RC channel
uint16_t *channel;
// pwm value after interpolation
int pwm;
// opening serial port for serial communication with Sabertooth and SBUS
sbus = open_file(port_name_1, "rb");
sabertooth = open_file(port_name_2, "w+");
// read data from RC transmitter using sbus
read_SBUS(sbus_packet, uint8_t, 25, sbus);
// parsing sbus packet
channel = parse_buffer(sbus_packet);
// get pwm range for Sabertooth 1
pwm = interpolation(channel[0]); // write
// to
// write data to Sabertooth 1 // sabertooth
write_to_SB(sabertooth, "%d", pwm);
// closing all serial port
close_file(sbus);
close_file(sabertooth);
}