Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (SBGuy), 712 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Developing broker plugin, "BrokerCommand" causes wrong nTicks #483814
07/29/21 20:58
07/29/21 20:58
Joined: Jul 2020
Posts: 4
M
maccam912 Offline OP
Guest
maccam912  Offline OP
Guest
M

Joined: Jul 2020
Posts: 4
I wasn't sure where to post this. I know there is free support for developers writing C++ plugins. My plugin is in Rust, and is just a POC.

When I don't have "BrokerCommand" defined "BrokerHistory2" is called with "nTicks" = 300, as expected. Dates for start and end are parsed just fine etc.

When I define a "BrokerCommand" function that simply is returning 0 no matter what the arguments are everything falls apart for my "BrokerHistory2". nTicks is int::min (-2147483648), tStart is -89434288.33333333 and tEnd is -89434078.4252956. Needless to say, my broker doesn't have history from that far back laugh

Does anyone here have any ideas as to why just defining "BrokerCommand" here is causing this problem? The Rust FFI has been working fine until now.

Re: Developing broker plugin, "BrokerCommand" causes wrong nTicks [Re: maccam912] #483815
07/29/21 21:09
07/29/21 21:09
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
I have never seen this happen in C++. Maybe force GET_MAXTICKS to output 300?

Otherwise, check to see if there's any problems with your build process/options. Check your struct alignment (1 byte).

Re: Developing broker plugin, "BrokerCommand" causes wrong nTicks [Re: maccam912] #483818
07/30/21 00:55
07/30/21 00:55
Joined: Jul 2020
Posts: 4
M
maccam912 Offline OP
Guest
maccam912  Offline OP
Guest
M

Joined: Jul 2020
Posts: 4
What is most baffling to me is that having BrokerCommand defined, and called, is what causes the weird arguments. Here is an example with what all the arguments to BrokerHistory2 are:

[Linked Image]

And here is when it works, when BrokerCommand is not defined:

[Linked Image]

Structs seem to be aligned. The only one I'm using is T6, and from the docs I have it aligned to 4 bytes.

Re: Developing broker plugin, "BrokerCommand" causes wrong nTicks [Re: maccam912] #483823
07/30/21 11:42
07/30/21 11:42
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
I'm not very familiar with Rust, but BrokerCommand returns double, not int. Maybe your implementation returns strange values because of a wrong return type.

Re: Developing broker plugin, "BrokerCommand" causes wrong nTicks [Re: maccam912] #483829
07/30/21 20:12
07/30/21 20:12
Joined: Jul 2020
Posts: 4
M
maccam912 Offline OP
Guest
maccam912  Offline OP
Guest
M

Joined: Jul 2020
Posts: 4
Well turns out jcl isn't a chief engineer for nuthin'. That was exactly my problem. After fixing the return type everything worked exactly as expected. Thanks for the help!

Re: Developing broker plugin, "BrokerCommand" causes wrong nTicks [Re: maccam912] #486993
12/15/22 20:12
12/15/22 20:12
Joined: Dec 2022
Posts: 3
F
Ferris Offline
Guest
Ferris  Offline
Guest
F

Joined: Dec 2022
Posts: 3
Hey everyone,
I'm replying to this post because I'm very much interested in using Rust with Zorro, as Rust is my favorite programming language that I'm using for almost everything.
(And this is the only forum thread that comes up when I search for Rust.)

@maccam912:
How is it going with Rust & Zorro? Would you be interested in collaborating?
I've been using Rust since 2014 and I'm working as a Rust fullstack developer, I've written quite a bit of FFI code in Rust over the years to interact with C/C++ libs.
It would be nice if we could pool our efforts instead of duplicating efforts in writing FFI. What do you think? smile

I'm also curious if there are other Rustaceans on this forum who would be interested in collaborating on writing Rust FFI.

Last edited by Ferris; 12/15/22 20:12.

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1