Welcome to the forum   
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Share
Options
View
Go to last post in this topic Go to first unread post in this topic
Offline Olle3770  
#1 Posted : 17 October 2012 12:53:03(UTC)
Olle3770

Sweden   
Joined: 29/01/2009(UTC)
Posts: 75
Location: Eskilstuna, Sweden
Hi again.

Noticed that there is a new version of the cs2CAN-Protokoll document available. Thought I take a new run at using it from a PC.

However, the document leaves a lot to wish for. Right now I have problems with the "Anfordern Config Data"-protocol. When I issue the 'loks' or the 'lokstat' commands (the one I've tried) I get data back from the CS2. So far so good. The length of the messages back seems to be correct but there are two issues remaining:

1.) The CRC doesn't compute. At least not with the algorithm given in the document.
2.) The data is said to be ZLib-compressed. I have tried at least 6 different ZLib-imlementations (Microsoft .Net/C#) but none of them are able to inflate/uncompress the data.

So, have anybody any further information on this topic? The protocol documentation supplied by M seems sketchy at the best.

Offline Olle3770  
#2 Posted : 20 October 2012 21:00:37(UTC)
Olle3770

Sweden   
Joined: 29/01/2009(UTC)
Posts: 75
Location: Eskilstuna, Sweden
Disappointing.

But what to expect? If I re-phrase the question: Does anybody know any e-mail address @ marklin where one (I) could ask this simple question? They do supply documentation so I guess the intention is to make it useful. All I need are some clarifications.

Thanx for listening.

//OBj
Offline Olle3770  
#3 Posted : 22 October 2012 14:30:42(UTC)
Olle3770

Sweden   
Joined: 29/01/2009(UTC)
Posts: 75
Location: Eskilstuna, Sweden
Victory! Finally figured it out. Still have issues with the CRC, but the data inflates fine and seems to be the lokomotive.cs2-file currently in effect.

Need to do some more testing later but it looks promising. If things work out as expected there will be no need to sip through the backup-files to get the current CS2 configuration.

We can drop this now.



CRC now calculates correctly. Just tested it all on my CS2 right now and I can make changes to locomotives (for instance update max speed) in the CS2 and directly upload the change to the PC. Sweet.



//OBj

Edited by user 22 October 2012 19:32:09(UTC)  | Reason: More info.

Offline Olle3770  
#4 Posted : 24 October 2012 23:40:50(UTC)
Olle3770

Sweden   
Joined: 29/01/2009(UTC)
Posts: 75
Location: Eskilstuna, Sweden
Is anybody working on something similar to a PCStation - a Mobile Station but on a PC? Actually I'm getting there if only I have the stamina. Getting the current locomotive data, layout, switch positions etc. from the Central Station 2 works perfectly. I even discovered that the CS2 spontaneously sends most updates made to locomotives, layouts, routes, switch definitions etc whenever they are saved on the CS2.

A lot of work remains of course.

I'm doing this in MS .Net 4.0/C# (Visual Studio 2010). It's a heavily multi-threaded application so it's a pain to debug.

But perhaps this is old news and pretty uninteresting.

Well, back to work...

//OBj
Offline Danlake  
#5 Posted : 25 October 2012 06:46:01(UTC)
Danlake

New Zealand   
Joined: 03/08/2011(UTC)
Posts: 1,571
Hi Olle,

I am reading your post to see if I can learn something (in a field I know nothing about!).

Have you considered being member of the Marklin Digital club newsletter. As a member you can write (or call) Tom Cathrell - the Marklin expert.

I think membership was only 25US.

Brgds - Lasse
Digital 11m2 layout / C (M&K) tracks / Era IV / CS3 60226 / Train Controller Gold 9 with 4D sound. Mainly Danish and German Locomotives.
Offline Olle3770  
#6 Posted : 26 October 2012 22:17:58(UTC)
Olle3770

Sweden   
Joined: 29/01/2009(UTC)
Posts: 75
Location: Eskilstuna, Sweden
Thank you for your tip, I've considered it before but you gave me the push to do it. I applied for Digital and Insider today. The dollar is cheap in Sweden so what the h*ck.

//OBj
Offline Fabrice  
#7 Posted : 18 November 2012 14:49:52(UTC)
Fabrice


Joined: 01/12/2010(UTC)
Posts: 10
Location: Johannesburg
Originally Posted by: Olle3770 Go to Quoted Post
Is anybody working on something similar to a PCStation - a Mobile Station but on a PC? Actually I'm getting there if only I have the stamina. Getting the current locomotive data, layout, switch positions etc. from the Central Station 2 works perfectly. I even discovered that the CS2 spontaneously sends most updates made to locomotives, layouts, routes, switch definitions etc whenever they are saved on the CS2.

A lot of work remains of course.

I'm doing this in MS .Net 4.0/C# (Visual Studio 2010). It's a heavily multi-threaded application so it's a pain to debug.

But perhaps this is old news and pretty uninteresting.

Well, back to work...

//OBj


Hi Olle,

Would like to write my own app to control my layouts. Am not satisfied what is on the market...

But for now, am battling to do the basics, like send STOP and START to the CS2... Can you share what you have done?
Once I understand the basics of the CAN protocol, specially how to get and interpret the UDP data, then I would be able to build exciting stuff... And more than happy to share back it to you.

Hope hearing from you soon.


Kind regards, Fabrice
Offline Webmaster  
#8 Posted : 18 November 2012 15:29:07(UTC)
Webmaster


Joined: 25/07/2001(UTC)
Posts: 11,161
This is very interesting, I think...

Do you have a link to the updated CAN document?
Juhan - "Webmaster", at your service...
He who asks a question is a fool for five minutes. He who does not ask a question remains a fool forever. [Old Chinese Proverb]
Offline tulit  
#9 Posted : 19 November 2012 14:08:20(UTC)
tulit

Canada   
Joined: 20/05/2012(UTC)
Posts: 400
Originally Posted by: Webmaster Go to Quoted Post
This is very interesting, I think...

Do you have a link to the updated CAN document?


http://medienpdb.maerkli...cs2CAN-Protokoll-2_0.pdf
Offline Olle3770  
#10 Posted : 23 November 2012 11:00:58(UTC)
Olle3770

Sweden   
Joined: 29/01/2009(UTC)
Posts: 75
Location: Eskilstuna, Sweden
Originally Posted by: Fabrice Go to Quoted Post

Hi Olle,

Would like to write my own app to control my layouts. Am not satisfied what is on the market...

But for now, am battling to do the basics, like send STOP and START to the CS2... Can you share what you have done?
Once I understand the basics of the CAN protocol, specially how to get and interpret the UDP data, then I would be able to build exciting stuff... And more than happy to share back it to you.

Hope hearing from you soon.


Kind regards, Fabrice


Hi Fabrice!
What language/environment are you writing your software in?

I can share what I have done, but right now it's all "work in progress" and a sore mess. I would take a lot of time to explain and everything will change over time. Most of it is just "Proof of Concept" (POC).

Communicating with the CS2 is easy - the problem is understanding what all messages really means - the documentation could be better. But for the basic stuff, like to control the speed and direction of locos and maneuvering switches is trivial. I haven't looked into the S88 feedback part yet, but I foresee no problems there.

The big news in version 2.0 of the CAN-document was the ability to interrogate the database in the CS2 - as well as finding out that changes in the CS2 are broadcasted over UDP. Very nice for a "PC Station". There is as far as I know no way to change anything IN the CS2 from a client - which makes sense. The CS2 is the master. It took some time to understand how to receive and unpack the database-data from the CS2 though.

For the moment I'm laying low. I have been able to negotiate some significant space in the house from my better half to build a real static layout. Most of my thinking now revolves around that. Since it will be automated with the help of a computer I'm still researching the topic. Right now I just know it's possible and worth the effort to write software to control the layout through the CS2.

You can always PM/eMail me with questions. A forum thread might be inappropriate (?) since it would become quite chatty over time i guess.

Best Regards
//OBj
thanks 1 user liked this useful post by Olle3770
Offline fvri  
#11 Posted : 30 January 2013 17:04:13(UTC)
fvri


Joined: 07/10/2002(UTC)
Posts: 773
Location: Zwevezele,
Originally Posted by: tulit Go to Quoted Post
Originally Posted by: Webmaster Go to Quoted Post
This is very interesting, I think...

Do you have a link to the updated CAN document?


http://medienpdb.maerkli...cs2CAN-Protokoll-2_0.pdf



Now I got the CS2 protocol document with support for S88 events maybe some update for LocCommander :).
Thx.

Although I don't have a CS2 so difficult to develop. I'll stick to my ECoS1.

br,
Frank
thanks 1 user liked this useful post by fvri
Offline TouchCab  
#12 Posted : 26 August 2013 13:50:00(UTC)
TouchCab

Denmark   
Joined: 04/03/2009(UTC)
Posts: 149
Location: Denmark
Originally Posted by: Olle3770 Go to Quoted Post
Victory! Finally figured it out. Still have issues with the CRC, but the data inflates fine and seems to be the lokomotive.cs2-file currently in effect.
...
CRC now calculates correctly. Just tested it all on my CS2 right now and I can make changes to locomotives (for instance update max speed) in the CS2 and directly upload the change to the PC.


Hello OBj

What was the solution(s)?
I am having exactly the same problem right now. It seems like the zlib data is not formatted correctly.


Best regards,
Jens
---
This account is no longer active
Offline TouchCab  
#13 Posted : 26 August 2013 22:50:34(UTC)
TouchCab

Denmark   
Joined: 04/03/2009(UTC)
Posts: 149
Location: Denmark
Never mind - I found a workaround.
This is why I think that from the programmer's view, the CS2 is such a strange device.

There are 3 ways to get information about the status of the accessories:
1) The page magnetartikel.cs2
2) The page magnetartikel.sr2
3) Request config data command

The trouble is that 1) and 2) are not neccessarily up to date, so you can't trust the info.
For whatever reason, the data reply for 3) is compressed, and as far as I can see right now, the compression format is bad. I could be wrong here, though ...

Anyway, it seems that the info on the magnetartikel.sr2 page is updated when a request config data command is sent, so what I do is send the command, wait for the reply, ignore it and load the .sr2 page. Then I got the updated info I want in plain XML.

I mean, if you take the time and trouble to compress the file with the valid info, it should be no major problem to keep all the information sources updated ... or at the very least update the xml page that you made a compressed version of.

And let's not mention that a threeway turnout (or point for the brits) has four states, where straight may be state 1 and 3.

Oh well, that nut is cracked - now I can start dealing with the various accessories.

Edited by user 30 August 2013 03:21:09(UTC)  | Reason: Not specified

Best regards,
Jens
---
This account is no longer active
thanks 3 users liked this useful post by TouchCab
Offline TouchCab  
#14 Posted : 29 August 2013 23:38:43(UTC)
TouchCab

Denmark   
Joined: 04/03/2009(UTC)
Posts: 149
Location: Denmark
One more thing I have come across in the protocol:

On the lokomotive.cs2 page there is a field called '..dauer', which is supposed to indicate if a loco function is momentary or not (according to protocol v2.0).
However, it seems like Märklin is not using this field, but is instead using the highest bit of the symbol number byte to indicate momentary function.

This has caused me some confusion, since there are only 112 symbol icons, but e.g. a momentary loco horn is symbol #138. Of course, subtracting 128 yields function #10, which is the horn, and with a high bit for momentary, and everything falls into place.

CS2 software v3.0.1 used.

Best regards,
Jens
---
This account is no longer active
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

| Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.795 seconds.