Modbus slave Component problem

For general Flowcode discussion that does not belong in the other sections.
Post Reply
User avatar
p.erasmus
Posts: 434
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Modbus slave Component problem

Post by p.erasmus »

Hi Ben /leigh.

I am working on a Modbus slave however I have a problem in understanding the GetLastIncoming() macro

First this macro is not in the wiki :D

P2.jpg
P2.jpg (35.9 KiB) Viewed 2464 times
secondly it seems it can index 4 bytes (0-3 shown in the parameters) and it returns a number

I assume the returned number is how many bytes was read from the Incoming transaction,
so if the master send Slave Address ,Command action(read coils etc) and Address of the command action it would return value 3 and the macro will have data in index 0, index 1 and index 2

my issue is now how to access the index bytes ? :oops:
please help me understand this it is quite urgent Please :D

P1.jpg
P1.jpg (54.43 KiB) Viewed 2464 times
Regards Peter - QME Electronics

BenR
Matrix Staff
Posts: 1952
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 510 times
Been thanked: 698 times

Re: Modbus slave Component problem

Post by BenR »

Hi Peter,

The GetLastIncoming macro is fairly new and allows you to see what the last incoming command from the master was. This allows you to action a change as it happens rather then having to poll all the various modbus registers and locations for a change.

An index value of 0 returns if the last command was a read or write command.
Index value of 1 returns the memory type that was accessed.
Index value of 2 returns the address within the memory type.
Index value of 3 returns the value that was read/written.

The GetLastIncoming only works for singluar values so if the master read/wrote a number of variables at once then the GetLastIncoming will only return the first value/address. We could maybe add a new index 4 to return the number of registers accessed if this would be useful.

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: Modbus slave Component problem

Post by p.erasmus »

never mind
Regards Peter - QME Electronics

Post Reply