Skip to content

Commit 029c521

Browse files
committed
make robolibrary
1 parent 2eda199 commit 029c521

24 files changed

+890
-2
lines changed

draft/test_woof/Makefile

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# Makefile
3+
#
4+
5+
CC := gcc
6+
CCPP := g++
7+
8+
OBJECTSC := $(patsubst %.c, %.o, $(wildcard *.c))
9+
OBJECTSCPP := $(patsubst %.cpp, %.o, $(wildcard *.cpp))
10+
11+
TARGET := $(patsubst %.o, %, $(OBJECTSC)) $(patsubst %.o, %, $(OBJECTSCPP))
12+
13+
CFLAGS := -I. -DLINUX=1
14+
LIBRARIES := -lpthread -lrt
15+
16+
.PHONY: all clean
17+
18+
all: $(OBJECTSC) $(OBJECTSCPP)
19+
20+
%.o: %.c
21+
$(CC) $(CFLAGS) -o $(patsubst %.o, %, $@) $< $(LIBRARIES)
22+
23+
%.o: %.cpp
24+
$(CCPP) $(CFLAGS) -o $(patsubst %.o, %, $@) $< $(LIBRARIES)
25+
26+
clean:
27+
rm -f *.o $(TARGET)
28+
29+
targets:
30+
echo "[i] targets: $(TARGET)"
31+
32+
rebuild:
33+
make clean
34+
make

draft/test_woof/dog_woof.wav

51.5 KB
Binary file not shown.

draft/test_woof/test.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// test
3+
//
4+
5+
#include <stdio.h>
6+
#include <stdlib.h>
7+
8+
int main(int argc, char* argv[])
9+
{
10+
printf("[i] Start...\n");
11+
12+
13+
14+
printf("[i] End.\n");
15+
16+
return 0;
17+
}

draft/test_woof/test_aplay.cpp

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//
2+
// test
3+
//
4+
5+
#include <stdio.h>
6+
#include <stdlib.h>
7+
#include <unistd.h>
8+
9+
#include <sys/types.h>
10+
#include <sys/wait.h>
11+
12+
int main(int argc, char* argv[])
13+
{
14+
printf("[i] Start...\n");
15+
16+
int return_value;
17+
18+
#if 0
19+
return_value = system("aplay dog_woof.wav");
20+
21+
printf("[i] return: %d\n", return_value);
22+
#endif
23+
24+
int child_status = -1;
25+
pid_t child_pid;
26+
27+
printf("[i] main program process ID is %d\n", (int)getpid());
28+
29+
child_pid = fork();
30+
if(child_pid == 0) {
31+
//printf("[i] child process, with id %d\n", (int)getpid());
32+
33+
return_value = execl("/usr/bin/aplay", "aplay", "dog_woof.wav");
34+
//printf("[i] return: %d\n", return_value);
35+
36+
return 0;
37+
}
38+
else {
39+
printf("[i] parent process, with id %d\n", (int) getpid());
40+
printf("[i] childs process ID is %d\n", (int) child_pid);
41+
}
42+
43+
wait( &child_status );
44+
printf("[i] status: %d\n", child_status);
45+
46+
if (WIFEXITED (child_status)) {
47+
printf ("the child process exited normally, with exit code %d\n", WEXITSTATUS (child_status));
48+
}
49+
else {
50+
printf ("the child process exited abnormally\n");
51+
}
52+
53+
printf("[i] End.\n");
54+
55+
return 0;
56+
}

draft/test_woof/test_aplay2.cpp

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//
2+
// test
3+
//
4+
5+
#include <stdio.h>
6+
#include <stdlib.h>
7+
#include <unistd.h>
8+
9+
#include <sys/types.h>
10+
#include <sys/wait.h>
11+
12+
int main(int argc, char* argv[])
13+
{
14+
printf("[i] Start...\n");
15+
16+
int return_value;
17+
18+
printf("[i] main program process ID is %d\n", (int)getpid());
19+
20+
int counter=0;
21+
while(counter++<10) {
22+
printf("[i] counter %d\n", counter);
23+
24+
int child_status = -1;
25+
pid_t child_pid;
26+
27+
child_pid = fork();
28+
if(child_pid == 0) {
29+
//printf("[i] child process, with id %d\n", (int)getpid());
30+
31+
return_value = execl("/usr/bin/aplay", "aplay", "dog_woof.wav");
32+
//printf("[i] return: %d\n", return_value);
33+
34+
return 0;
35+
}
36+
else {
37+
printf("[i] parent process, with id %d\n", (int) getpid());
38+
printf("[i] childs process ID is %d\n", (int) child_pid);
39+
}
40+
41+
wait( &child_status );
42+
printf("[i] status: %d\n", child_status);
43+
44+
if (WIFEXITED (child_status)) {
45+
printf ("the child process exited normally, with exit code %d\n", WEXITSTATUS (child_status));
46+
}
47+
else {
48+
printf ("the child process exited abnormally\n");
49+
}
50+
}
51+
52+
printf("[i] End.\n");
53+
54+
return 0;
55+
}

lib/Makefile

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Makefile for make crossfunctions
3+
#
4+
5+
CC := g++
6+
TARGET :=
7+
8+
OBJECTS := $(patsubst %.cpp, %.o, $(wildcard *.cpp))
9+
10+
LIBPATH := ..
11+
12+
CFLAGS := -I. -I$(LIBPATH) -DLINUX=1
13+
# flags for debug
14+
CFLAGSD := -I. -I$(LIBPATH) -DLINUX=1 -O0 -g
15+
# flags for release
16+
CFLAGSR := -I. -I$(LIBPATH) -DLINUX=1 -O3
17+
18+
LIBRARIES := -lpthread -lrt
19+
20+
21+
.PHONY: all clean
22+
23+
all: $(OBJECTS)
24+
25+
%.o: %.cpp
26+
$(CC) $(CFLAGS) -c -o $@ $< $(LIBRARIES)
27+
28+
debug:
29+
make CFLAGS="$(CFLAGSD)"
30+
31+
release:
32+
make CFLAGS="$(CFLAGSR)"
33+
34+
clean:
35+
rm -f *.o $(TARGET)

orcp2/buffer.h lib/buffer.h

File renamed without changes.

lib/commands.h

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
//
3+
// available commands
4+
//
5+
// robocraft.ru
6+
//
7+
8+
#ifndef _COMMANDS_H_
9+
#define _COMMANDS_H_
10+
11+
#include "types.h"
12+
13+
#define SIG_SIZE 6
14+
15+
typedef struct CmdAcknowledgment {
16+
char sig[SIG_SIZE]; // "ackmnt"
17+
int32_t code;
18+
19+
} CmdAcknowledgment;
20+
21+
typedef struct CmdDrive2WD {
22+
char sig[SIG_SIZE]; // "drive2"
23+
int16_t pwm[2];
24+
25+
} CmdDrive2WD;
26+
27+
typedef struct CmdSpeech {
28+
char sig[SIG_SIZE]; // "speech"
29+
uint32_t code;
30+
char name[64];
31+
32+
} CmdSpeech;
33+
34+
typedef struct CmdTelemetry2WD {
35+
char sig[SIG_SIZE]; // "tlmtry"
36+
uint8_t Bamper;
37+
int16_t pwm[2];
38+
uint32_t US;
39+
uint32_t IR;
40+
uint32_t Voltage;
41+
42+
} CmdTelemetry2WD;
43+
44+
#endif //#ifndef _COMMANDS_H_

orcp2/console.cpp lib/console.cpp

File renamed without changes.

orcp2/console.h lib/console.h

File renamed without changes.

orcp2/network.cpp lib/network.cpp

File renamed without changes.

orcp2/network.h lib/network.h

File renamed without changes.

0 commit comments

Comments
 (0)