749 views
in System Integration by
Hallo :)

I have a Photo sensor which is connected to a Arduino. I'm sending the Calculated Value via rx tx connection to my raspberry pi 3b +.

 

I updated the devicedriver file with this code for my recieving value (just to try at the moment) :

int DeviceDriver_ProcessData( void )
{
  int needUpdate = 0;

    int i = 0;
    char aString[3];
    int fd;
    int aInt = 0;
    char hundred;
    char ten;
    char one;

    if((fd = serialOpen ("/dev/ttyAMA0",9600))<0)
    {
        return 1;
    }

    for(i = 0; i <= 2; i++)
    {
    aString[i] = serialGetchar (fd);
    fflush (stdout);
    }

    for(i = 0; i <= 2; i++)
    {
    if(i == 0) {hundred = aString[i];}
    if(i == 1) {ten = aString[i];}
    if(i == 2) {one = aString[i];}
    }

    aInt = (((hundred - '0')*100) + ((ten - '0')*10) + (one - '0'));

    ApplicationDeviceClass__UpdateTerminalInt(DeviceObject, (XInt32) aInt);
    needUpdate = 1;

return needUpdate;

In code Blocks the Code works fine. I guess there is something wrong with my funktion ApplicationDeviceClass__UpdateTerminalInt(DeviceObject,(XInt32) aInt).

Befor this try i rebuild your example :

https://ask.embedded-wizard.de/433/how-to-send-string-from-usart-and-show-it-textviewer-in-the-gui?show=433#q433

And i thought i could change it to recieve a integer and use it in gauge but i don't get it .

 

Could you help me ? Maybe a short example would help me.

 

Best greetings from Austria

Jules

1 Answer

0 votes
by
Hello Jules,

can you explain what in your actual implementation is not working? Or what aspect of the implementation you don't understand?

Best regards

Paul Banach
by

Hi :)

 

How can i use this resieved integer (in my Program aInt) variabl to show it in my gauge ?

 

At the moment i updated my DeviceDriver.c file with my c code :

int DeviceDriver_ProcessData( void )
{
  int needUpdate = 0;

    int i = 0;
    char aString[3];
    int fd;
    int aInt = 0;
    char hundred;
    char ten;
    char one;


    if((fd = serialOpen ("/dev/ttyAMA0",9600))<0)
    {
        return 1;
    }

    for(i = 0; i <= 2; i++)
    {
    aString[i] = serialGetchar (fd);
    fflush (stdout);
    }

    for(i = 0; i <= 2; i++)
    {
    if(i == 0) {hundred = aString[i];}
    if(i == 1) {ten = aString[i];}
    if(i == 2) {one = aString[i];}
    }

    aInt = (((hundred - '0')*100) + ((ten - '0')*10) + (one - '0'));

    ApplicationDeviceClass__UpdateTerminalInt(DeviceObject, (XInt32) aInt);
    needUpdate = 1;

 

return needUpdate;

 

My EmbeddedWizard looks like this :

 

 

The TerminalObservers outlet is on: ^TerminalInt

OnEvent is on : onTerminalEvent

The Outlet of the Gauge is on: ^TerminalInt

 

Prototyping and Code generating works well.

Wen i try to create on raspberry via sudo make following error message apears:

../Source/DeviceDriver.c:248:47: error: 'DeviceObject' undeclared (first use in this function)

 

Thanks for your fast answer and sorry for my bad english :)

Best regards

Jules

by

Hello Jules,

the problem here, you have defined the property TerminalInt and the method UpdateTerminalInt() within the Application class. In the C code, however, you call the function  ApplicationDeviceClass__UpdateTerminalInt(), which according to its name is expected to be defined in the class DeviceClass. Usually, we recommend to implement all interface specific functionality within a DeviceClass. Implementing the interface within the Application class, however, is not problematic. So for the first test, you can leave it as it is.

What you can try is to change the function call to following (diferences are in bold):

ApplicationApplication__UpdateTerminalInt( RootObject, (XInt32) aInt );
 

Now, the C code will call a function corresponding to the method UpdateTerminalInt() from the Application class. The unique remaining problem, you have to call this function with the instance of the application in its first parameter. Such instance is created at the startup time of the application and stored usually in a variable RootObject. So I hope you can compile this code already.

I recommend you also the following thread: How to set current value for Gauge??

Best regards

Paul Banach

by
OK i got it :)

 

I added a DeviceClass and tried it again with ApplicationDeviceClass__UpdateTerminalInt(DeviceObject, (XInt32) aInt).

Everything works fine. now i can continue with my project.

Thanks for your fast replies, you realy helped me :)

Best regards

Jules

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...