Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ICRE - ESP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ricardo Andres Ercoli Auersperg
ICRE - ESP
Commits
55c3d3ff
Commit
55c3d3ff
authored
2 years ago
by
RicardoEA
Browse files
Options
Downloads
Patches
Plain Diff
Uart to send/receive floats
parent
9b7ee85b
Branches
prueba_de_conexion
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Robotito/src/control/control.c
+13
-3
13 additions, 3 deletions
Robotito/src/control/control.c
Robotito/src/main.c
+16
-7
16 additions, 7 deletions
Robotito/src/main.c
with
29 additions
and
10 deletions
Robotito/src/control/control.c
+
13
−
3
View file @
55c3d3ff
...
...
@@ -117,9 +117,19 @@ static void callback_odometry(){
o
->
y_dot
=
v
->
y
;
o
->
phi
+=
v
->
z
*
OMNI_ODOM_CTRL_TIMER
;
o
->
phi_dot
=
v
->
z
;
char
*
Txdata
=
(
char
*
)
malloc
(
100
);
sprintf
(
Txdata
,
"Hello world index
\r\n
"
);
uart_write_bytes
(
UART_NUM_2
,
Txdata
,
strlen
(
Txdata
));
//char* Txdata = (char*) malloc(100);
//sprintf (Txdata, "Hello world index \r\n");
//uart_write_bytes(UART_NUM_2, Txdata, strlen(Txdata));
float
float_buffer
[
6
];
//float_buffer = o;
float_buffer
[
0
]
=
o
->
x
;
float_buffer
[
1
]
=
o
->
x_dot
;
float_buffer
[
2
]
=
o
->
y
;
float_buffer
[
3
]
=
o
->
y_dot
;
float_buffer
[
4
]
=
o
->
phi
;
float_buffer
[
5
]
=
o
->
phi_dot
;
uart_write_bytes
(
UART_NUM_2
,
float_buffer
,
sizeof
(
float_buffer
));
free
(
v
);
}
...
...
This diff is collapsed.
Click to expand it.
Robotito/src/main.c
+
16
−
7
View file @
55c3d3ff
...
...
@@ -27,15 +27,17 @@
static
const
char
*
tag
=
"UART EVENT"
;
#define UART_NUM UART_NUM_2
#define BUF_SIZE 1024
#define FLOAT_BUF_SIZE 4
#define BUF_SIZE FLOAT_BUF_SIZE * sizeof(float)
#define TASK_MEMORY 1024 * 2
static
QueueHandle_t
uart_queue
;
static
uint8_t
data
[
BUF_SIZE
];
static
float
fdata
[
FLOAT_BUF_SIZE
];
static
void
uart_task
(
void
*
pvParameters
)
{
uart_event_t
event
;
uint8_t
*
data
=
(
uint8_t
*
)
malloc
(
BUF_SIZE
);
int
len
;
while
(
1
)
{
...
...
@@ -45,12 +47,19 @@ static void uart_task(void *pvParameters)
switch
(
event
.
type
)
{
case
UART_DATA
:
len
=
uart_read_bytes
(
UART_NUM
,
data
,
event
.
size
,
portMAX_DELAY
);
if
(
len
>
0
){
len
=
uart_read_bytes
(
UART_NUM
,
data
,
BUF_SIZE
,
portMAX_DELAY
);
if
(
len
==
BUF_SIZE
){
memcpy
(
&
fdata
,
data
,
sizeof
(
fdata
));
printf
(
"%s
\n
"
,
data
);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
printf
(
"El dato %d en float es: %f
\n
"
,
i
,
fdata
[
i
]);
}
// decodificar mensaje y hacer omni_drive
uart_flush
(
UART_NUM
);
}
else
{
printf
(
"Todavia no se completo el mensaje o hay un error.
\n
"
);
}
// decodificar mensaje y hacer omni_drive
uart_flush
(
UART_NUM
);
break
;
default:
ESP_LOGI
(
tag
,
"uart event type: %d"
,
event
.
type
);
...
...
@@ -74,7 +83,7 @@ static void init_uart(void)
uart_set_pin
(
UART_NUM
,
5
,
4
,
UART_PIN_NO_CHANGE
,
UART_PIN_NO_CHANGE
);
uart_driver_install
(
UART_NUM
,
BUF_SIZE
,
BUF_SIZE
,
5
,
&
uart_queue
,
0
);
uart_driver_install
(
UART_NUM
,
BUF_SIZE
*
2
,
BUF_SIZE
*
2
,
5
,
&
uart_queue
,
0
);
xTaskCreate
(
uart_task
,
"uart_task"
,
TASK_MEMORY
,
NULL
,
5
,
NULL
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment