Fix
This commit is contained in:
parent
120010f39c
commit
e94442e12b
@ -7,11 +7,4 @@ project(stm32)
|
|||||||
|
|
||||||
add_subdirectory(app) #application
|
add_subdirectory(app) #application
|
||||||
add_subdirectory(bsp) #board support package, lwip
|
add_subdirectory(bsp) #board support package, lwip
|
||||||
add_subdirectory(libs/stm32f4xx) #stm32f4xx library
|
add_subdirectory(libs/stm32f4xx) #stm32f4xx library
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
set(elf_file stm32.elf)
|
set(elf_file stm32.elf)
|
||||||
|
|
||||||
# set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/nanopb/extra)
|
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/nanopb/extra)
|
||||||
# find_package(Nanopb REQUIRED)
|
find_package(Nanopb REQUIRED)
|
||||||
|
|
||||||
# nanopb_generate_cpp(TARGET proto simple.proto)
|
nanopb_generate_cpp(TARGET proto simple.proto)
|
||||||
|
|
||||||
add_executable(${elf_file}
|
add_executable(${elf_file}
|
||||||
main.c
|
main.c
|
||||||
@ -12,7 +12,7 @@ add_executable(${elf_file}
|
|||||||
|
|
||||||
target_link_libraries(${elf_file} PUBLIC
|
target_link_libraries(${elf_file} PUBLIC
|
||||||
bsp
|
bsp
|
||||||
# proto
|
proto
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(${elf_file} PRIVATE
|
target_include_directories(${elf_file} PRIVATE
|
||||||
|
62
app/main.c
62
app/main.c
@ -1,37 +1,37 @@
|
|||||||
#include "../bsp/bsp.h"
|
#include "../bsp/bsp.h"
|
||||||
// #include <pb_encode.h>
|
#include <pb_encode.h>
|
||||||
// #include <pb_decode.h>
|
#include <pb_decode.h>
|
||||||
// #include "simple.pb.h"
|
#include "simple.pb.h"
|
||||||
|
|
||||||
// void serialzie() {
|
void serialzie() {
|
||||||
// /* This is the buffer where we will store our message. */
|
/* This is the buffer where we will store our message. */
|
||||||
// uint8_t buffer[128];
|
uint8_t buffer[128];
|
||||||
// size_t message_length;
|
size_t message_length;
|
||||||
// bool status;
|
bool status;
|
||||||
|
|
||||||
// /* Encode our message */
|
/* Encode our message */
|
||||||
// {
|
{
|
||||||
// SimpleMessage message = SimpleMessage_init_zero;
|
SimpleMessage message = SimpleMessage_init_zero;
|
||||||
|
|
||||||
// /* Create a stream that will write to our buffer. */
|
/* Create a stream that will write to our buffer. */
|
||||||
// pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
|
pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
|
||||||
|
|
||||||
// /* Fill in the lucky number */
|
/* Fill in the lucky number */
|
||||||
// message.number = 42;
|
message.number = 42;
|
||||||
// /* Now we are ready to encode the message! */
|
/* Now we are ready to encode the message! */
|
||||||
// status = pb_encode(&stream, SimpleMessage_fields, &message);
|
status = pb_encode(&stream, SimpleMessage_fields, &message);
|
||||||
// message_length = stream.bytes_written;
|
message_length = stream.bytes_written;
|
||||||
// printf('%d\r\n', buffer);
|
|
||||||
// // udp_send_data(buffer, message_length);
|
udp_send_data(buffer, message_length);
|
||||||
// /* Then just check for any errors.. */
|
/* Then just check for any errors.. */
|
||||||
// if (!status)
|
if (!status)
|
||||||
// {
|
{
|
||||||
// printf("Encoding failed: %s\n", PB_GET_ERROR(&stream));
|
printf("Encoding failed: %s\n", PB_GET_ERROR(&stream));
|
||||||
// return 1;
|
return 1;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// return 0;
|
return 0;
|
||||||
// }
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
@ -42,12 +42,12 @@ int main(void)
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
// lwipProcess();
|
lwipProcess();
|
||||||
const char *data = "Hello, world!";
|
const char *data = "Hello, world!";
|
||||||
sprintf(numStr, "%d", cnt++);
|
sprintf(numStr, "%d", cnt++);
|
||||||
char* strCat = strcat(data, numStr);
|
char* strCat = strcat(data, numStr);
|
||||||
// udp_send_data(numStr, strlen(numStr));
|
// udp_send_data(numStr, strlen(numStr));
|
||||||
// serialzie();
|
serialzie();
|
||||||
// printf("Test\r\n");
|
// printf("Test\r\n");
|
||||||
GPIO_ToggleBits(GPIOB, GPIO_Pin_14);
|
GPIO_ToggleBits(GPIOB, GPIO_Pin_14);
|
||||||
delay(100);
|
delay(100);
|
||||||
|
@ -52,7 +52,7 @@ void udpServer_init(void)
|
|||||||
if (err == ERR_OK) {
|
if (err == ERR_OK) {
|
||||||
// printf("UDP bind\r\n");
|
// printf("UDP bind\r\n");
|
||||||
}
|
}
|
||||||
// IP4_ADDR(&remote_ip, 192, 168, 1, 111);
|
IP4_ADDR(&remote_ip, 192, 168, 1, 111);
|
||||||
// err= udp_connect(upcb, &remote_ip, remote_port);
|
// err= udp_connect(upcb, &remote_ip, remote_port);
|
||||||
if (err == ERR_OK) {
|
if (err == ERR_OK) {
|
||||||
// printf("UDP connect\r\n");
|
// printf("UDP connect\r\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user