String as output in DLL

Antworten
PowerSoft
Beiträge: 22
Registriert: Samstag 8. Oktober 2011, 12:43
Wohnort: Hellevoetsluis-NL

String as output in DLL

Beitrag von PowerSoft » Freitag 22. Juni 2018, 14:10

Hello,

I'm working on a ISS tracker. To do the heavy calculations I use a DLL. My program environment is the Dev-C++compiler.
My DLL is working perfect, have used the well know SGP4 routines witch can be found on the Web.
Now I need to output some information as a string. Have looked to all the examples and discussions here on the forum.
Without a result.
Please can someone help me out with this?

With kindly regards

Jan
Hellevoetsluis-NL
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........

Müllmann
Beiträge: 64
Registriert: Sonntag 2. Februar 2014, 10:53

Re: String as output in DLL

Beitrag von Müllmann » Freitag 22. Juni 2018, 20:16

Hello,

try the appended StringDLL, that i wrote just for testing.
The source is with german comments.
May be, the DLL is uesfull for you.

Regards
Dateianhänge
StringDLL.zip
(7.44 KiB) 201-mal heruntergeladen
Ich bin der Müllmann und räume nur auf.

Mike D
Beiträge: 528
Registriert: Dienstag 14. Oktober 2008, 14:48
Wohnort: Elbe- Weser-Dreieck

Re: String as output in DLL

Beitrag von Mike D » Samstag 23. Juni 2018, 10:14

Hej,
one important point is, that the names of the string-ports have to begin with a dolar sign.

Mike

PowerSoft
Beiträge: 22
Registriert: Samstag 8. Oktober 2011, 12:43
Wohnort: Hellevoetsluis-NL

Re: String as output in DLL

Beitrag von PowerSoft » Samstag 23. Juni 2018, 11:04

Vielen Dank,

das ist, was ich gesucht habe ;)

Jan
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........

PowerSoft
Beiträge: 22
Registriert: Samstag 8. Oktober 2011, 12:43
Wohnort: Hellevoetsluis-NL

Re: String as output in DLL

Beitrag von PowerSoft » Samstag 23. Juni 2018, 11:34

In you're code you mentiod "Stringein-/ausgabe nach Beispiel aus Profilab"
Wich example is this?


Thanks and regards,

Jan
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........

Müllmann
Beiträge: 64
Registriert: Sonntag 2. Februar 2014, 10:53

Re: String as output in DLL

Beitrag von Müllmann » Samstag 23. Juni 2018, 18:15

In my directory of Profilab is following path to a StringDLL
/Profilab/Beispiele/Neue_Funktionen/Strings/DLL
May be, you can find it in /Profilab/Examples/New_Functions/Strings/DLL
I have zipped the directory of the C++ example, see appendix
Dateianhänge
HexToWord_DLL C++Builder source.zip
(55.88 KiB) 174-mal heruntergeladen
Ich bin der Müllmann und räume nur auf.

PowerSoft
Beiträge: 22
Registriert: Samstag 8. Oktober 2011, 12:43
Wohnort: Hellevoetsluis-NL

String as output in DLL is crashing Profilab

Beitrag von PowerSoft » Dienstag 26. Juni 2018, 20:17

Hello,

I have a working DLL thats calculate the position of Satellites.

This is my call to execute :
//Call from PROFILAB, this is the actual function call DLL
1. DLLEXPORT void _stdcall CCalculate(double *PInput, double *POutput, double *PUser, StringParam PStrings)
2. DLLEXPORT void _stdcall CCalculate(double *PInput, double *POutput, double *PUser)

When I use line 1. Profilab is crashing.
When I use line 2. in my code the program is running perfect.
Have tested under windows 7-32bit and windows 10-64bit.

Include my complete project.
What is going wrong?

I know it is a complicated program, but thanks for any help.

Jan
ISS_ProfiLab.zip
(476.28 KiB) 186-mal heruntergeladen
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........

abacom
Site Admin
Beiträge: 3917
Registriert: Dienstag 23. September 2008, 10:54
Kontaktdaten:

Re: String as output in DLL is crashing Profilab

Beitrag von abacom » Mittwoch 27. Juni 2018, 08:02

First of all please make sure to have latest ProfiLab update installed, if you haven´t yet.
ABACOM support

PowerSoft
Beiträge: 22
Registriert: Samstag 8. Oktober 2011, 12:43
Wohnort: Hellevoetsluis-NL

Re: String as output in DLL is crashing Profilab

Beitrag von PowerSoft » Mittwoch 27. Juni 2018, 15:04

I have used the version from : 07-05-2018
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........

PowerSoft
Beiträge: 22
Registriert: Samstag 8. Oktober 2011, 12:43
Wohnort: Hellevoetsluis-NL

Re: String as output in DLL

Beitrag von PowerSoft » Mittwoch 27. Juni 2018, 19:21

Hello,

I have constructed a simple DLL thats should output a string named longstr1.
I don't get it to work I think it is a matter of conversion.
What to do to get it running?
Thanks allot for any help.



Code: Alles auswählen

#include "GetFromNorad.h"

char longstr1[]="1 25544U 98067A   18161.85073725  .00003008  00000-0  52601-4 0  9993";
char longstr2[]="2 25544  51.6418  50.3007 0003338 171.6979 280.7366 15.54163173117534";

//Number of inputs 
unsigned char inputs 		=  1;  
//Number of outputs
unsigned char outputs 		= 1; 
//index for input variables
const unsigned char CLK     = 0;
//index for user variables
const unsigned char CLK_OLD = 0;

typedef unsigned char *PChar;
typedef PChar *StringParam[100];
char OutString[1000]; 

//Call from PROFILAB, get number of inputs 
DLLEXPORT unsigned char _stdcall NumInputs()
{
      return inputs;
}
  
//Call from ProfiLab, get number of outputs
DLLEXPORT unsigned char _stdcall NumOutputs()
{
      return outputs;
}
  

DLLEXPORT void _stdcall GetInputName(unsigned char Channel, char *Name)
{
      if (Channel == 0) strcpy(Name,"CLK");
}
  

DLLEXPORT void _stdcall GetOutputName(unsigned char Channel, char *Name)
{
	if (Channel == 0) strcpy(Name,"$Satelite");
}
  
//Aufruf von PROFILAB, setzt bei Programmstart den "Counter"auf "0"+ setzt alle Ausgaenge zurueck
DLLEXPORT void _stdcall CSimStart(double *PInput, double *POutput, double *PUser)
{  
}
  
//Call from PROFILAB, this is the actual function call DLL
DLLEXPORT void _stdcall CCalculate(double *PInput, double *POutput, double *PUser, StringParam PStrings)
{
     if (PInput[CLK] < 2.5)  //Input CLK low?
      {
            if (PUser[CLK_OLD] > 2.5) //falling edge CLK?
            {
            	strcpy(PChar(PStrings[0]),longstr1);
            }
			      }
      PUser[CLK_OLD] = PInput[CLK]; // Value of CLC stored for next cyclus
}
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........

abacom
Site Admin
Beiträge: 3917
Registriert: Dienstag 23. September 2008, 10:54
Kontaktdaten:

Re: String as output in DLL

Beitrag von abacom » Donnerstag 28. Juni 2018, 08:11

Note that method name must be...
C++: void _stdcall CCalculateEx(double *PInput, double *POutput, double *PUser; StringParam PStrings)
for string processing.
You seem to have missed the "Ex"?
ABACOM support

PowerSoft
Beiträge: 22
Registriert: Samstag 8. Oktober 2011, 12:43
Wohnort: Hellevoetsluis-NL

Re: String as output in DLL

Beitrag von PowerSoft » Donnerstag 28. Juni 2018, 14:00

Thanks this was helpful, it is now running ;)
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........

Antworten

Zurück zu „DLL-Programmierung“