Closed krupis closed 2 years ago
Hi, You also need to enable FreeRTOS CMSIS_v2 under the middleware section in CubeMX. I updated the README to reflect this requirement.
Thats great. I have managed to build project with your library. I have a few questions additional questions:
The DMA configuration does not require the circular mode. Check the corresponding examples.
Also check the following file, it contains an example for the modbus master
Examples/ModbusF429/Core/Src/freertos.c
Thats great. I used the example that you have given to read slave register:
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN 5 */
/* Infinite loop */
uint32_t u32NotificationValue;
telegram.u8id = 1; // slave address
telegram.u8fct = 3; // function code (this one is registers read)
//telegram[0].u16RegAdd = 0x160; // start address in slave
telegram.u16RegAdd = 0x0; // start address in slave
telegram.u16CoilsNo = 1; // number of elements (coils or registers) to read
telegram.u16reg = ModbusDATARX; // pointer to a memory array
/* Infinite loop */
for(;;)
{
ModbusQuery(&ModbusH, telegram); // make a query
u32NotificationValue = ulTaskNotifyTake(pdTRUE, 500); // block until query finishes or timeout
if(u32NotificationValue)
{
DEBUG_PRINT("modbus responded \n");
//handle error
// while(1);
}
osDelay(500);
}
/* USER CODE END 5 */
}
I can see on the logic analyzer that the data has been requested and sent.
I tried to debug what is happening in the code line by line but it seems very complicated and there are multiple layers behind this (Multiple freertos tasks, multiple queues and etc...)
I have been able to confirm that whenever I send data, SendQuery is getting executed. What I am confused about is the following:
When I step the code with breakpoints, I can see that the case case MB_FC_READ_INPUT_REGISTER: is activated. I dont understand why that happens since I send modbus request with funcion code 3 so case MB_FC_READ_REGISTERS: should be activated (Not sure why its empty)
Another question that I have: Do you have a modbus parser implemented to print messages console? I mean when I send command to read certain register. For example I want to read multiple slave 1 coil status with address offset 5. Is there any way to printf result to the console for example: [SLAVE1] COIL5 = 0 [SLAVE1] COIL6 = 1 [SLAVE1[ COIL7 = 0
At the moment, I can see that my commands are working and I can send requests to read various registers but there is no point reading anything if I cant see the output.
Im sorry for troubling you so much
At the m
Hi, MB_FC_READ_REGISTERS is not empty, it is handled by the code shown in line #870 of the code.
There is no functions to print to the console. In the example, you can check the data coming from the slave in the ModbusDATARX buffer, you can use breakpoints to verify that or print to the console by yourself.
Hello. I have downloaded your modbus library and I am trying to use it. I use STM32F407. I have followed the steps that you have suggested:
When I try to build the project, I get 30 errors ( most of them are due to unknown types)
Project build log:
For example, in Modbus.c, multiple types are not recognised: