Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Tier2, arduino, compile agk to tier1

Author
Message
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 12:00 Edited at: 19th Feb 2019 12:03
Hi !

Sorry i'm newbie with c++

i'm searching a way to include something like this (https://blog.manash.me/serial-communication-with-an-arduino-using-c-on-windows-d08710186498) directly into agk as commands for tier1.

So :

- Could i use Visual studio EXPRESS to compile all the tiers2 agk sourcecode to an exe (what's the best version) with my new commands (c++) and next continue to use only tier1 ?

i just need the news commands for the arduino. i hope next use only tier1.


(note : i've also codeblocks and c++ installed on my pc)

many many thanks !

(windows 10).

The author of this post has marked a post as an answer.

Go to answer

Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 19th Feb 2019 12:22 Edited at: 19th Feb 2019 12:25
What your after is being able to send and receive data on a serial port. AppGameKit currently doesn't support serial port access directly but there are ways to do it.

What you can do is write an AppGameKit plugin to do this in windows
https://www.appgamekit.com/documentation/guides/14_plugins.htm

You put the serial com port open routine into the plugin.....this is a .DLL file then you can access new functions from within your AppGameKit teir 1 code and write a few read and write functions

Something similar to:
OpenSerialPort(port as string, baud as integer)
WriteSerialByte(port as integer, data as integer)
ReadSerialByte(port as integer, data as integer)
CloseSerialPort(port as integer)


The code you linked to could be put into the functions above then used in teir 1. I know this.... as its exactly what I had to do for a work project to get serial port access from within AGK. Id post the code, but as I was paid to do this at work I will have to ask for permission to give it out. Its also fairly easy to write to be honest. I used visual studio to write the plugin and commands similar to the above ones. Via the serial port you can communicate to raspberry pi's, odroids, arduinos, etc...


A slighty simpler alternative is to use the Arduino as a USB joystick class device then use the inbuilt joystick functions to get data that way....this was don by Dybing I think
[href=https://forum.thegamecreators.com/thread/216460]https://forum.thegamecreators.com/thread/216460
[/href]

Another alternative is to get a wifi sheild for the arduino and simply communicate using AGK's TCP or UDP commands directly to the arduino.

If that doesnt seem appealing you can buy Serial to TCP bridge PCB's...they are around 12euros or so. They simply have a network lead at one end and a set of serial pins at the other. You connect the serial pins to the arduino and then wire up a network lead from your router to the arduino. That works but is a little clumsy.
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 17:38
Many thanks Bengismo. Dll seems to be easy to produce and include !
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 19:00
i've some difficulties to find the function names that GCC created for my function (called the mangled or decorated name). They will look something like this ?CreateRedSquare@@YAXXZ, but where to find this ?
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 19th Feb 2019 19:20
From AGK's guide I posted above:
AGK's plugin guide wrote: "When you have created your plugin you will need to find the function names that Visual Studio or GCC created for your functions (called the mangled or decorated name). They will look something like this ?CreateRedSquare@@YAXXZ and can be discovered using a DLL explorer like Dependency Walker. "

Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 19:31
yes but i've not found this name from Dependency Walker !
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 19:40
My cpp code :


h file :
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 19:48 Edited at: 19th Feb 2019 20:16
....

Attachments

Login to view attachments
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 19:59

Attachments

Login to view attachments
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 19th Feb 2019 20:00 Edited at: 19th Feb 2019 20:03
The only function that is exported in the first screenshot and it is named SomeFunction at entry point 1260

Easy...lol

In your second screen shot there is a whole list of functions....

It may be best if you go test your dll in a simple program as per the example plugins. Also try the example plugins that come with AppGameKit and compile those so you know how to do this.
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 20:17 Edited at: 19th Feb 2019 20:18
i'm here...



so i'm trying now to use tier1... to be continued
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 20:30

Attachments

Login to view attachments
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 20:36


grrrr !!

Attachments

Login to view attachments
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 20:56
#CommandName,ReturnType,ParameterTypes,Windows,Linux,Mac,Android,iOS,Windows64
Travaille@@YAXXZ,0,SS,_Z9TravaillePKcS0_,0,0,0,0,0

???
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 21:00
what's wrong ?
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 21:13
Hope a dll game guru help me with this ! i don't understand the error message !
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 21:43
i've uploaded the dll file.
Perhaps somebody here know how to find the Travaille decorated name !

DLL_EXPORT void Travaille(const char *numero_port,const char *Commande)
{
}

Attachments

Login to view attachments
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 22:25
Commands.txt :
#CommandName,ReturnType,ParameterTypes,Windows,Linux,Mac,Android,iOS,Windows64
Travaille,0,SS,Travaille,0,0,0,0,0

or

#CommandName,ReturnType,ParameterTypes,Windows,Linux,Mac,Android,iOS,Windows64
Travaille,0,SS,Travaille,_Z9TravaillePKcS0_,0,0,0,0

->

main.agc:13: error: Failed to load plugin HubertArduinoSerie, command list /Plugins/HubertArduinoSerie/Commands.txt does not have enough tokens per line
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 22:30 Edited at: 19th Feb 2019 22:31

to avoid mangled or decorated name

Attachments

Login to view attachments
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 19th Feb 2019 22:32
Mais c'est pas possible cette galère !!!

(sorry french, do not translate).
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 20th Feb 2019 07:10
I don't know if you are using the example plugin and if your plugin still has this function.




This is necessary. If you don't want to use internal AppGameKit functions, you can leave them empty. I don't know if the Create- and DeleteString functions are important.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 20th Feb 2019 07:17
after gcc compile next inside dependency walker i've not name like '?AddFloat@@YAMMM@Z' somewhere as the example plugin commands.txt. (ive onlythis : _Z9TravaillePKcS0_)
perhaps i can find this somewhere into dependency walker ?
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 20th Feb 2019 07:21 Edited at: 20th Feb 2019 07:21
@MadBit : should i paste your code snippet inside my cpp code ? (i don't find it inside the example plugin .cpp file)
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 20th Feb 2019 07:30 Edited at: 20th Feb 2019 08:37
deleted

Attachments

Login to view attachments
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 20th Feb 2019 07:33 Edited at: 20th Feb 2019 08:12
deleted

Attachments

Login to view attachments
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 20th Feb 2019 08:11
always : main.agc:13: error: Failed to load plugin HubertArduinoSerie, command list /Plugins/HubertArduinoSerie/Commands.txt does not have enough tokens per line

with :

#CommandName,ReturnType,ParameterTypes,Windows,Linux,Mac,Android,iOS,Windows64
Travaille,0,SS,_Z9TravaillePKcS0_,0,0,0,0,0

and this


Attachments

Login to view attachments
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 20th Feb 2019 08:35 Edited at: 20th Feb 2019 08:40
my project is inside a zip file. If somebody could try it with CodeBlocks or see what's wrong.

my error :

main.agc:13: error: Failed to load plugin HubertArduinoSerie, command list /Plugins/HubertArduinoSerie/Commands.txt does not have enough tokens per line

with :

#CommandName,ReturnType,ParameterTypes,Windows,Linux,Mac,Android,iOS,Windows64
Travaille,0,SS,_Z9TravaillePKcS0_,0,0,0,0,0

Perhaps a ParametersTypes issue ?

DLL_EXPORT void Travaille(const char *numero_port,const char *Commande)
{
}

is correct ?

after gcc compile next inside dependency walker i've not name like '?AddFloat@@YAMMM@Z' somewhere as the example plugin commands.txt. (i've only this : _Z9TravaillePKcS0_)
perhaps i can find this somewhere into dependency walker ?

Many thanks for your help.

Attachments

Login to view attachments
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 20th Feb 2019 08:42
Quote: "should i paste your code snippet inside my cpp code ? (i don't find it inside the example plugin .cpp file)"

No it is not complete.

The minimal one is this. I Think.



But this function is also in AGKLibraryCommands.cpp of this example from AppGameKit-Documentation
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 20th Feb 2019 09:01
The DLL in your zip works. At least the compiler runs without errors and the program is executed.

Command.txt

Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 20th Feb 2019 09:14
it works for you inside AppGameKit ?
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 20th Feb 2019 09:18 Edited at: 20th Feb 2019 09:19
yep - Tier 1 -

Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Hubert BAYRE
6
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 20th Feb 2019 09:28
This post has been marked by the post author as the answer.
it works here too after a copy paste from your code Snippet inside the Commands.txt file ! But why ?

Magic !

Many thanks !!!!!! ++++
Rick Nasher
6
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 22nd Feb 2019 01:27
Hi guys,

Interesting thread. Hope you can answer my question:

Based on earlier comments(in another thread) I actually was under the impression DLL's couldn't be used to add features to AppGameKit, such as extra physics commands, for would then only work under Windows when using Tier1.

Is this incorrect then?
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 22nd Feb 2019 05:30
If you compile the DLL under Linux as .so and under Mac as dylib. Then adjust the command.txt. then you can also use the plugin under Linux and MacOS.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)

Login to post a reply

Server time is: 2024-04-18 08:31:47
Your offset time is: 2024-04-18 08:31:47