Seite 1 von 1

String as output in DLL

Verfasst: Freitag 22. Juni 2018, 14:10
von PowerSoft
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

Re: String as output in DLL

Verfasst: Freitag 22. Juni 2018, 20:16
von Müllmann
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

Re: String as output in DLL

Verfasst: Samstag 23. Juni 2018, 10:14
von Mike D
Hej,
one important point is, that the names of the string-ports have to begin with a dolar sign.

Mike

Re: String as output in DLL

Verfasst: Samstag 23. Juni 2018, 11:04
von PowerSoft
Vielen Dank,

das ist, was ich gesucht habe ;)

Jan

Re: String as output in DLL

Verfasst: Samstag 23. Juni 2018, 11:34
von PowerSoft
In you're code you mentiod "Stringein-/ausgabe nach Beispiel aus Profilab"
Wich example is this?


Thanks and regards,

Jan

Re: String as output in DLL

Verfasst: Samstag 23. Juni 2018, 18:15
von Müllmann
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

String as output in DLL is crashing Profilab

Verfasst: Dienstag 26. Juni 2018, 20:17
von PowerSoft
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) 202-mal heruntergeladen

Re: String as output in DLL is crashing Profilab

Verfasst: Mittwoch 27. Juni 2018, 08:02
von abacom
First of all please make sure to have latest ProfiLab update installed, if you haven´t yet.

Re: String as output in DLL is crashing Profilab

Verfasst: Mittwoch 27. Juni 2018, 15:04
von PowerSoft
I have used the version from : 07-05-2018

Re: String as output in DLL

Verfasst: Mittwoch 27. Juni 2018, 19:21
von PowerSoft
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
}

Re: String as output in DLL

Verfasst: Donnerstag 28. Juni 2018, 08:11
von abacom
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"?

Re: String as output in DLL

Verfasst: Donnerstag 28. Juni 2018, 14:00
von PowerSoft
Thanks this was helpful, it is now running ;)