Hi all
Now I would like to do this: I want my project is readable but just for some parts, not all parts.
In fact I would like some functions could be used as I wrote them, without modifications.
Could you try to explain simply me how to do this, if possible ?
Thanks
How to compile some parts ?
- aleksa.jovanovic
- Posts: 526
- Joined: 30 Jun 2015 08:48
Re: How to compile some parts ?
Hi,
I'm not really sure I understand what you mean.
Do you want to protect the source code, the HEX, or something else?
Best regards,
Aleksa.
I'm not really sure I understand what you mean.
Do you want to protect the source code, the HEX, or something else?
Best regards,
Aleksa.
-
- Posts: 240
- Joined: 16 Jan 2010 22:26
Re: How to compile some parts ?
Sorry for my bad english
Suppose you made , on one sheet of your project, special display functions like "Print_On_Two_Lines_With_Clock(char *DisplayString, char TimeDelay, char StringColor)" ...
Now, on main sheet, suppose you didn't want future programmer can modify display functions (as you do on Mikroc because I think we can't modifiy "TFT_Write_Text" function )
I would like to do so: my personnal code for some functions will be fixed although main code may be updated.
Is it more clear ?
Another thing I remember writing word "delay" here: there is a problem with delay function. if you write "Delay_ms(10)" it work but, as I needed variable delay ion some cases, I tried to do a delay function like this
it works ... but just for short delay !
Suppose you made , on one sheet of your project, special display functions like "Print_On_Two_Lines_With_Clock(char *DisplayString, char TimeDelay, char StringColor)" ...
Now, on main sheet, suppose you didn't want future programmer can modify display functions (as you do on Mikroc because I think we can't modifiy "TFT_Write_Text" function )
I would like to do so: my personnal code for some functions will be fixed although main code may be updated.
Is it more clear ?
Another thing I remember writing word "delay" here: there is a problem with delay function. if you write "Delay_ms(10)" it work but, as I needed variable delay ion some cases, I tried to do a delay function like this
Code: Select all
void SpecialDelayFunction(char Timems)
{
char x1;
for (x1=0;x1<=Timems,x1++) delay_ms(1);
}
Re: How to compile some parts ?
Put all your private code in one or more source file. After compiling the project, for each source file the compiler will generate MCL file. These are compiled binaries. In your distribution version of the project, remove the private source files and add their compiled versions (*.mcl) in the Project Explorer window (Binaries).orpheedulogis wrote:I would like to do so: my personnal code for some functions will be fixed although main code may be updated.
Is it more clear ?
It will never work that way because you have to take into account the execution time of other instructions. However, you don't even have to do that since there is already built-in Vdelay_ms function which takes a variable as argument.orpheedulogis wrote:Another thing I remember writing word "delay" here: there is a problem with delay function. if you write "Delay_ms(10)" it work but, as I needed variable delay ion some cases, I tried to do a delay function like this
it works ... but just for short delay !Code: Select all
void SpecialDelayFunction(char Timems) { char x1; for (x1=0;x1<=Timems,x1++) delay_ms(1); }
Regards
-
- Posts: 240
- Joined: 16 Jan 2010 22:26
Re: How to compile some parts ?
Thanks a lot
For Vdelay it will be OK
For compiling I'm not sure
First I can't see "mcl" files but only "emcl". Are they the same ?
Second, could you confirm me:
- I make a new project with specific text sheets I want to be unmodifiable
- I compile them
- I move the result file in a global project (".emcl" file ?)
- add a new #include "FixedFunctions" in main file
Can you explain me very simply ?
Regards
Update:
I searched. perhaps I have to do like this (please confirm)
1) make a specific project with functions I want to protect, compiling project
2) copy emcl generated file in "C:\Program Files (x86)\mikroC PRO for ARM\Uses\ST M4" (I use STM32F407)
3) use my "old" project, removing sheets I want to be unreadable
4) import "emcl" file as library
Am I OK ?
For Vdelay it will be OK
For compiling I'm not sure
First I can't see "mcl" files but only "emcl". Are they the same ?
Second, could you confirm me:
- I make a new project with specific text sheets I want to be unmodifiable
- I compile them
- I move the result file in a global project (".emcl" file ?)
- add a new #include "FixedFunctions" in main file
Can you explain me very simply ?
Regards
Update:
I searched. perhaps I have to do like this (please confirm)
1) make a specific project with functions I want to protect, compiling project
2) copy emcl generated file in "C:\Program Files (x86)\mikroC PRO for ARM\Uses\ST M4" (I use STM32F407)
3) use my "old" project, removing sheets I want to be unreadable
4) import "emcl" file as library
Am I OK ?
Re: How to compile some parts ?
To distribute your project you need to do the following:
1. Compile the original project
2. Duplicate your original project folder
3. Delete source files you want to hide (*.c)
4. Add compiled versions of the deleted source files to the project (*.emcl)
That's it.
Regards
1. Compile the original project
2. Duplicate your original project folder
3. Delete source files you want to hide (*.c)
4. Add compiled versions of the deleted source files to the project (*.emcl)
That's it.
Regards
-
- Posts: 240
- Joined: 16 Jan 2010 22:26
Re: How to compile some parts ?
Sorry
On Easymx pro board, with original STM32F107 processor
I made a very simple "project" -one sheet- with only one function to display a specific word, and one variable
(like "void DisplayHello(char ApparitionNumber)" )
Of course this function cannot work alone but it compile so I got an "emcl" file.
I copy this file in library folder, close mikroC so it can upadate and took an example project ("TFT_main")
problem: how can I tell to the example I have a new library (I can't see it !) so I can call "DisplayHello(10)" ?
I tried to put this emcl file directly in the project directory but it's the same problem: how to declare this library ?
---------------------------------------------------------------------------------------------
update
Please just confirm this is OK
I cancelled what I did before.
- I made a normal programmation (many sheets)
- I build the project to verify all is OK
- I removed files I didn't want to be modified ( "*.c" and "*.c.ini" files)
Doing this I can close , re-open MikroC, compile main without error message.
Is it so simple ?
On Easymx pro board, with original STM32F107 processor
I made a very simple "project" -one sheet- with only one function to display a specific word, and one variable
(like "void DisplayHello(char ApparitionNumber)" )
Of course this function cannot work alone but it compile so I got an "emcl" file.
I copy this file in library folder, close mikroC so it can upadate and took an example project ("TFT_main")
problem: how can I tell to the example I have a new library (I can't see it !) so I can call "DisplayHello(10)" ?
I tried to put this emcl file directly in the project directory but it's the same problem: how to declare this library ?
---------------------------------------------------------------------------------------------
update
Please just confirm this is OK
I cancelled what I did before.
- I made a normal programmation (many sheets)
- I build the project to verify all is OK
- I removed files I didn't want to be modified ( "*.c" and "*.c.ini" files)
Doing this I can close , re-open MikroC, compile main without error message.
Is it so simple ?
Re: How to compile some parts ?
Yes, it is very simple. You just need to add binaries to your project. In the Project Explorer window right-click on "Binaries" -> "Add files to project..." and select the *.emcl files that contain the code you want to keep private.orpheedulogis wrote:Sorry
update
Please just confirm this is OK
I cancelled what I did before.
- I made a normal programmation (many sheets)
- I build the project to verify all is OK
- I removed files I didn't want to be modified ( "*.c" and "*.c.ini" files)
Doing this I can close , re-open MikroC, compile main without error message.
Is it so simple ?
Regards
-
- Posts: 240
- Joined: 16 Jan 2010 22:26
Re: How to compile some parts ?
OK
Thanks a lot
Thanks a lot
-
- Posts: 240
- Joined: 16 Jan 2010 22:26
Re: How to compile some parts ?
Now, another thing:
Suppose
1) in a "h" definition file, for example "Definition1.h"
2) In first project, main zone
3) now, in second project (who will give me "emcl" file) I need Led definition so I copied "Definition1.h" file in directory. In this project main will just have included files
4) Now, I get back to first project and added "emcl" file in directory
If I compile it gived me an error, telling Led1 as been redefined
I suppose that it's because compilator separe "emcl" declarations.
Is there a solution for this ?
Suppose
1) in a "h" definition file, for example "Definition1.h"
Code: Select all
#ifndef PortDefinition
#define PortDefinition
sbit Led1 at GPIOA_ODR.B3;
#endif
2) In first project, main zone
Code: Select all
#include "Definition1.h"
void main()
{
char x1;
x1=Led1;
}
Code: Select all
#include "Definition1.h"
void main()
{
// nothing
}
If I compile it gived me an error, telling Led1 as been redefined
I suppose that it's because compilator separe "emcl" declarations.
Is there a solution for this ?
Re: How to compile some parts ?
It doesn't make sense to use emcl file with compiled main function because the other project will have its own main routine. The error you are receiving is because the sbit declaration is already part of the emcl. Also, emcl files are intended for libraries and it isn't wise to hardcode the pin declaration there. You should declare sbit as extern and the problem will be solved.
Regards
Regards
-
- Posts: 240
- Joined: 16 Jan 2010 22:26
Re: How to compile some parts ?
I understand
The problem I have is that I have now to find how I could extract some parts.
So I must modify my extracted parts before separating them. Next time I will prepare this differently.
Thanks
The problem I have is that I have now to find how I could extract some parts.
So I must modify my extracted parts before separating them. Next time I will prepare this differently.
Thanks