FreeModbus_Slave-Master-RTT-STM32 icon indicating copy to clipboard operation
FreeModbus_Slave-Master-RTT-STM32 copied to clipboard

How to read from slave?

Open emrelio opened this issue 5 years ago • 6 comments

I'm trying to read registers from the slave. But I can't read anything. With the ReqWrite function or FuncWrite function.

How can I read registers from the slave?

Thank You!

emrelio avatar Feb 24 '20 07:02 emrelio

You can ues this API

eMBMasterReqErrCode eMBMasterReqReadHoldingRegister( UCHAR ucSndAddr, 
                                                     USHORT usRegAddr,
                                                     USHORT usNRegs,
                                                     LONG lTimeOut );

armink avatar Feb 24 '20 09:02 armink

I'm trying with this function but I did write the wrong function name in the first message. Sorry.

But I couldn't find the variable to read the data. I mean which variable is for reading the data.

emrelio avatar Feb 24 '20 10:02 emrelio

You can find the read data on the usMRegHoldBuf in FreeModbus\port\user_mb_app_m.c

armink avatar Feb 24 '20 11:02 armink

Thank you! I did try to read but then I realized in every request the error code is always "TimeOut". Even in the reqWrite. I'm using f407 with 168MHz clock.

emrelio avatar Feb 27 '20 05:02 emrelio

May be uart driver has some problem. You can check the uart ISR for data receive.

armink avatar Feb 29 '20 06:02 armink

Thank you! I did try to read but then I realized in every request the error code is always "TimeOut". Even in the reqWrite. I'm using f407 with 168MHz clock.

me too!Have you solved the problem yet

miskin-lee avatar Dec 10 '21 07:12 miskin-lee