forked from gwealm/FEUP-RC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
46 lines (38 loc) · 1013 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
42
43
44
45
46
// Main file of the serial port project.
// NOTE: This file must not be changed.
#include <stdio.h>
#include <stdlib.h>
#include "application_layer.h"
#define BAUDRATE 9600
#define N_TRIES 3
#define TIMEOUT 4
// Arguments:
// $1: /dev/ttySxx
// $2: tx | rx
// $3: filename
int main(int argc, char *argv[])
{
if (argc < 4)
{
printf("Usage: %s /dev/ttySxx tx|rx filename\n", argv[0]);
exit(1);
}
const char *serialPort = argv[1];
const char *role = argv[2];
const char *filename = argv[3];
printf("Starting link-layer protocol application\n"
" - Serial port: %s\n"
" - Role: %s\n"
" - Baudrate: %d\n"
" - Number of tries: %d\n"
" - Timeout: %d\n"
" - Filename: %s\n",
serialPort,
role,
BAUDRATE,
N_TRIES,
TIMEOUT,
filename);
applicationLayer(serialPort, role, BAUDRATE, N_TRIES, TIMEOUT, filename);
return 0;
}