programming CV For MFX under BiDi

http://www.opendcc.de
http://www.bidib.org
peter_moulin
Posts: 40
Joined: 17.03.2010, 19:38

programming CV For MFX under BiDi

Post by peter_moulin » 11.01.2018, 05:39

Hello,

Programming a CV on POM with a bidi controller is OK with a DCC loco.
To programme a CV on POM with a MFX loco and a a bidi controller , the following has been introduced in bidi_messages.h
// c) opcodes for MSG_CS_POM/MSG_BM_XPOM (see at the end)

#define BIDIB_CS_POM4_RD_BYTE1 0xC0
#define BIDIB_CS_POM4_RD_BYTE2 0xC1
#define BIDIB_CS_POM4_RD_BYTE4 0xC2
#define BIDIB_CS_POM4_RD_BYTE8 0xC3 // reserved???
#define BIDIB_CS_POM4_WR_BYTE 0xC4

Is it possible to introduce those code in the official version to be able to read a CV on POM when the loco format is MFX?
A local test has proven the feasibility

rjversluis
Site Admin
Posts: 42306
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: programming CV For MFX under BiDi

Post by rjversluis » 11.01.2018, 09:01

Hi,

Code: Select all

0x80	BIDIB_CS_xPOM_reserved	XPoM (extended CV 24-Bit) reserviert
0x81	BIDIB_CS_xPOM_RD_BLOCK	XPoM (extended CV 24-Bit) 4-Byte-Block lesen
0x82	BIDIB_CS_xPOM_WR_BIT	XPoM (extended CV 24-Bit) Bit schreiben
0x83	BIDIB_CS_xPOM_WR_BYTE1	XPoM (extended CV 24-Bit) ein Byte schreiben
0x87	BIDIB_CS_xPOM_WR_BYTE2	XPoM (extended CV 24-Bit) zwei Bytes schreiben
0x8B	BIDIB_CS_xPOM_WR_BYTE3	XPoM (extended CV 24-Bit) drei Bytes schreiben
0x8F	BIDIB_CS_xPOM_WR_BYTE4	XPoM (extended CV 24-Bit) vier Bytes schreiben
I do not know which opcode. Is there any documentation?

Bergi
Posts: 105
Joined: 23.11.2016, 19:32

Re: programming CV For MFX under BiDi

Post by Bergi » 11.01.2018, 13:32

Hi Rob,
you've cited the opcodes for DCC XPoM, which IIRC was supported by RailcomPlus decoders.
rjversluis wrote:Is there any documentation?
There is no official specification for M4 (i.e. reverse-engineered MFX), but it pretty much works like usual CVs and will be transmitted in BiDiB using MSG_BM_XPOM / MSG_CS_POM with decoder address, opcode, cv index and cv data.

rjversluis
Site Admin
Posts: 42306
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: programming CV For MFX under BiDi

Post by rjversluis » 11.01.2018, 13:41

Hi Andreas,

OK, but I do not know which opcode to use.
The read is always 4 bytes? 32bit value?

Bergi
Posts: 105
Joined: 23.11.2016, 19:32

Re: programming CV For MFX under BiDi

Post by Bergi » 11.01.2018, 14:57

Hi Rob,
tbh I have no idea either, I guess you could just always read 4 bytes and then throw away those that you don't use. IIRC the mfx CVs are not even indexed linearly but organised in some kind of pages.
Does rocrail support programming/reading CV from the CentralStation or Ecos? Is there any ESU or Märklin documentation on how CVs work there?

rjversluis
Site Admin
Posts: 42306
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: programming CV For MFX under BiDi

Post by rjversluis » 11.01.2018, 15:01

Hi Andreas,

yes, Rocrail support programming for ecos and cs2/3, but the API is the same as for DCC.

But, why is there MFX support in BiDiB? Its DCC only...

peter_moulin
Posts: 40
Joined: 17.03.2010, 19:38

Re: programming CV For MFX under BiDi

Post by peter_moulin » 11.01.2018, 15:17

rjversluis wrote:Hi Andreas,

OK, but I do not know which opcode to use.
The read is always 4 bytes? 32bit value?
Hi,

Although you read or write in the same way, understanding a M4 CV is a bit different from understanding a DCC CV.
For more info refer to the following reverse engineering document http://www.skrauss.de/modellbahn/Schienenformat.pdf

With BiDi to read a DCC CV on PT you will send a MSG_CS_PROG with opcode BIDIB_CS_PROG_RD_BYTE, cv, 0
or POM
a MSG_CS_POM: with opcode BIDIB_CS_POM_RD_BYTE as described in MSG_CS_POM:

To read a M4 CV you will do the same but with the appropriate opcode. #define BIDIB_CS_POM4_RD_BYTE1 0xC0
Up to now GBM can only read one CV at a time.

CV value is send as an answer to MSG_CS_POM, It works for both DCC and M4. only how to analyse the result will differ.

Both M4 or DCC use an address and a CV number, called CV address in BiDi specs
Meaning of CV_Number for DCC or M4 are not the same. In DCC a CV has a unique number, where in M4 a CV has a value and an index to create a number.
Both are on 16 bits.
for M4: struct
{
unsigned char index: 6;
uint16_t value: 10;
};
or with low8 and high 8 CVL8 = VV IIII II, CVH8 = VVVV VVVV on 16 bits VVVV VVVV VV IIII II ; V=value and I=index.

For example to read the loco name, one will read CV_value 3 at index 0. If it reads 0x18, it is a nmae. Read the name by increasing the index.
0x53 0x4E 0x43 0x46 0x20 0x42 0x43 0x20 0x37 means SNCF BC 7 (in ASCII)

The difference in interface need to be in Rocview. You can't display a table with numbers and meaning as in DCC.
The best is most probably to display only three fields CV_address VVVV VVVV VV Index IIII II and value + a Read or write key

Is this understandable?
Last edited by peter_moulin on 11.01.2018, 15:23, edited 1 time in total.

peter_moulin
Posts: 40
Joined: 17.03.2010, 19:38

Re: programming CV For MFX under BiDi

Post by peter_moulin » 11.01.2018, 15:19

rjversluis wrote:Hi Andreas,

yes, Rocrail support programming for ecos and cs2/3, but the API is the same as for DCC.

But, why is there MFX support in BiDiB? Its DCC only...
Not exactly. I have implemented biprotocol in GBM and hopefully this will be use by more than myself.

rjversluis
Site Admin
Posts: 42306
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: programming CV For MFX under BiDi

Post by rjversluis » 11.01.2018, 15:25

Peter,
peter_moulin wrote:Not exactly. I have implemented biprotocol in GBM and hopefully this will be use by more than myself.
OK, but without understandable documentation this will not have a change.
I added the format byte as you proposed for the LOCO commands in bidib, but I have no clue how to handle your mfx pom.

peter_moulin
Posts: 40
Joined: 17.03.2010, 19:38

Re: programming CV For MFX under BiDi

Post by peter_moulin » 11.01.2018, 15:34

rjversluis wrote:Peter,
peter_moulin wrote:Not exactly. I have implemented biprotocol in GBM and hopefully this will be use by more than myself.
OK, but without understandable documentation this will not have a change.
I added the format byte as you proposed for the LOCO commands in bidib, but I have no clue how to handle your mfx pom.
Doc is bidi specs http://www.bidib.org/protokoll/bidib_co ... ion_e.html MSG_CS_POM: with opcode BIDIB_CS_POM4_RD_BYTE1 0xC0

attached a working example that I have tested in RocRail/bidi.c, I use it to read the name of a M4 loco
You do not have the required permissions to view the files attached to this post.

rjversluis
Site Admin
Posts: 42306
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: programming CV For MFX under BiDi

Post by rjversluis » 11.01.2018, 15:46

Hi Peter,

I do not see the need for a different approach.
Its all the same get/set with pom/xpom.
Why did you not map the DCC pom in your code? It make no sense to make a diff in Rocrail.
Or is the Bidib protocol not complex enough?

Rocrail source access is not for building locally only, and not to patch it with your own code.
Code is only changed by me.

Changes and additions should be discussed here, and I will implement it in case it makes sense.

smitt48
Moderator
Posts: 6111
Joined: 04.04.2014, 01:07
Location: Kralendijk, Bonaire - Dutch Caribbean

Re: programming CV For MFX under BiDi

Post by smitt48 » 11.01.2018, 16:01

Hi Rob,

In the ECoS there are no CVs you can read for mfx(m4). It just does not work the same way as DCC.

mfg Tom

rjversluis
Site Admin
Posts: 42306
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: programming CV For MFX under BiDi

Post by rjversluis » 11.01.2018, 16:08

Hi Tom,

if so, this kind of mfx programming is totally wrong, and should be handled with different opcodes.
Request with one number/index the train ID should respond with an array of bytes, not with a 16 bit value.

peter_moulin
Posts: 40
Joined: 17.03.2010, 19:38

Re: programming CV For MFX under BiDi

Post by peter_moulin » 11.01.2018, 17:10

rjversluis wrote:Hi Tom,

if so, this kind of mfx programming is totally wrong, and should be handled with different opcodes.
Request with one number/index the train ID should respond with an array of bytes, not with a 16 bit value.
You guess what the train should do, what is important is what the train does.
Please read the doc from Stefan Krauss first!

peter_moulin
Posts: 40
Joined: 17.03.2010, 19:38

Re: programming CV For MFX under BiDi

Post by peter_moulin » 11.01.2018, 17:12

rjversluis wrote:Hi Peter,

I do not see the need for a different approach.
Its all the same get/set with pom/xpom.
Why did you not map the DCC pom in your code? It make no sense to make a diff in Rocrail.
Or is the Bidib protocol not complex enough?

Rocrail source access is not for building locally only, and not to patch it with your own code.
Code is only changed by me.

Changes and additions should be discussed here, and I will implement it in case it makes sense.
not it is not "Its all the same get/set with pom/xpom."
The opcode is different

Post Reply

Return to “OpenDCC & BiDiB”