DCC-EX / Support-Planning

DCC++EX Repo to hold project planning documentation and processes
1 stars 1 forks source link

CPP DCC Commands #440

Closed fire-bot closed 1 year ago

fire-bot commented 1 year ago

Sent by Rick Grove (rgrove@tampabay.rr.com). Created by fire.


Hello,

I would like to programmatically issue DCC commands in the CommandStation-EX .ino.

This works:

include "DCCEXParser.h"

DCCEXParser csx;

Setup()

{…}

Loop()

{…

csx.parse(0,"<1 MAIN>",0);

csx.parse(0,"<t 10 10 1>",0);

}

But csx.parse(0,"<F 10 0 1>",0); does not work.

I have an Arduino Mega with an Arduino motor shield and all Serial Monitor commands work.

What is the correct way to do the cpp commands?

I’m trying to migrate a DCC++ automation scheme that I created to DCC-EX and will go to EX Rail at some future time.

Regards,

Rick

Asbelos commented 1 year ago

If you try and put commands in loop() you must understand that these will be executed hundreds of times a second... and if you attempt to slow this down, your cs will not run at all.

I strongly suggest you move to exrail where all the complexity of the arduino environment and cs timing is removed. Also, updating to the latest version of the cs will not lose your automation code.

If you did want to call the parser directly, the call would be LIKE THIS...

DCCEXParser::parse(F("<1 MAIN>"));

The fact that you could not see this used further up the .ino file you edited, suggests that you will have an enormous learning curve and it's all the more reason for going straight to exrail. If however you do want to understand how the cs works internally etc, please join our discord group where we are happy to discuss stuff like this.

In addition, if you are working in c++ there is no need to create commands and have the code parse them... you can make calls directly to the same DCC layer that the parser calls.

Asbelos commented 1 year ago

If you try and put commands in loop() you must understand that these will be executed hundreds of times a second... and if you attempt to slow this down, your cs will not run at all. I strongly suggest you move to exrail where all the complexity of the arduino environment and cs timing is removed. Also, updating to the latest version of the cs will not lose your automation code. If you did want to call the parser directly, the call would be LIKE THIS...DCCEXParser::parse(F("<1 MAIN>")); The fact that you could not see this used further up  the .ino file you edited, suggests that you will have an enormous learning curve and it's all the more reason for going straight to exrail. If however you do want to understand how the cs works internally etc, please join our discord group where we are happy to discuss stuff like this. On 10 Jun 2022 17:48, Fire @.***> wrote:

Sent by Rick Grove @.***). Created by fire.

Hello,

I would like to programmatically issue DCC commands in the CommandStation-EX .ino.

This works:

include "DCCEXParser.h"

DCCEXParser csx;

Setup()

{…}

Loop()

{…

csx.parse(0,"<1 MAIN>",0);

csx.parse(0,"<t 10 10 1>",0);

}

But csx.parse(0,"<F 10 0 1>",0); does not work.

I have an Arduino Mega with an Arduino motor shield and all Serial Monitor commands work.

What is the correct way to do the cpp commands?

I’m trying to migrate a DCC++ automation scheme that I created to DCC-EX and will go to EX Rail at some future time.

Regards,

Rick

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>