872 views
in GUI Development by
How to create UI for UART communication for STM32F769I Discovery board? Means I want to print the data what I am getting in Rx pin continuously in UI, which pins i have to use and how to create gui for that

1 Answer

0 votes
by
 
Best answer

Hello,

let me refer to the example 'DeviceIntegration' that you will find within the subdirectory /Examples of the Build Environment for STM32F769-Discovery. This example shows the integration of devices into a UI application.

The GUI implementation for presenting the data received via UART depends completely on your requirements and design ideas. Let me refer to our online documentation to get familiar with Embedded Wizard, e.g. the Quick Tour tutorial.

Best regards,

Manfred.

by

Hi Manfred,

Actually I am also doing same task what Mohsen Eghbal did: https://ask.embedded-wizard.de/433/how-to-send-string-from-usart-and-show-it-in-textviewer-the-gui?show=433#q433 . I followed all the steps what you told to do in that article but I am getting this error whenever I try to compile and upload a code to my board. I have added the code snippet to DeviceDriver ProcessData(); function in DeviceDriver.c file. Please help me.

Error:


Compiling ../../Source/DeviceDriver.c
../../Source/DeviceDriver.c: In function 'DeviceDriver_ProcessData':
../../Source/DeviceDriver.c:407:17: warning: implicit declaration of function 'EwBspGetCharacter'; did you mean 'EwGetCharLower'? [-Wimplicit-function-declaration]
  407 |       char ch = EwBspGetCharacter();
      |                 ^~~~~~~~~~~~~~~~~
      |                 EwGetCharLower
../../Source/DeviceDriver.c:409:22: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  409 |    if (( ch >= 'A' ) && ( ch <= 'Z' ) || ( ch >= 'a' ) && ( ch <= 'z' )
      |        ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
../../Source/DeviceDriver.c:411:22: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  411 |     || ( ch >= '0' ) && ( ch <= '9' ) || ( ch == ' ' ))
      |        ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
../../Source/DeviceDriver.c:415:5: warning: implicit declaration of function 'ApplicationDeviceClass__UpdateTerminalString'; did you mean 'ApplicationDeviceClass_OnSetTerminalString'? [-Wimplicit-function-declaration]
  415 |     ApplicationDeviceClass__UpdateTerminalString( DeviceObject, (XChar)ch );
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |     ApplicationDeviceClass_OnSetTerminalString
../../Source/DeviceDriver.c:415:51: error: 'DeviceObject' undeclared (first use in this function)
  415 |     ApplicationDeviceClass__UpdateTerminalString( DeviceObject, (XChar)ch );
      |                                                   ^~~~~~~~~~~~
../../Source/DeviceDriver.c:415:51: note: each undeclared identifier is reported only once for each function it appears in
make: *** [Obj/DeviceDriver.o] Error 1

    by
    Hello,

    based on the provided code snippet I cannot find the root cause for the compiler errors.

    It seems that the declaration and initialization of DeviceObject is missing. Please check your implementation regarding this.

    Best regards,

    Manfred.
    by

    Hi Manfred,

    I have added the below code to receive one character from the USART and to inform the device class about the new data. But it is giving error. 

    Step 4: Adaptation of the Device Driver to receive the character from USART

    The function DeviceDriver_ProcessData() is the right location to receive one character from the USART and to inform the device class about the new data. Just add the following C-code to this function:

    #ifdef _ApplicationDeviceClass_
    
    /* When a character is received from the serial terminal, call the method
    
         'UpdateTerminalString' of the device class 'DeviceClass' within the unit
    
         'Application' and provide the character */
    
          char ch = EwBspGetCharacter();
    
       if (( ch >= 'A' ) && ( ch <= 'Z' ) || ( ch >= 'a' ) && ( ch <= 'z' )
    
        || ( ch >= '0' ) && ( ch <= '9' ) || ( ch == ' ' ))
    
      { 
    
        ApplicationDeviceClass__UpdateTerminalString( DeviceObject, (XChar)ch );
    
        needUpdate = 1;
    
      }

    Where should i declare and initialize the variable DeviceObject.

    I referred and followed the steps you have mentioned in this article: https://ask.embedded-wizard.de/433/how-to-send-string-from-usart-and-show-it-in-textviewer-the-gui?show=434#a434

     

    by
    Hello,

    the problem is, that you are using some code snippets from 2017. The file DeviceIntegration.c has changed over the last five years....

    Which version of Embedded Wizard are you using?

    Please have a look to the current implementation of the example DeviceIntegration and the file DeviceDriver.c.

    The current implementation (with V12) contains a worker thread to provide data from a ADC to the GUI application. Take this as foundation for your application. Instead of sending single ADC values you can send the received characters from your UART.

    Does this help?

    Best regards,

    Manfred
    by
    Hi Manfred,

    I am not getting how to implement this. I am using Version 12 of Embedded Wizard. I just want to send a string from usart and show it in the GUI. Please guide me step by step how to do it.

    Thanks for your help.
    by

    Hello,

    the following explanations assumes that you are familiar with the example DeviceIntegration. You can use that as foundation.

    Step 1: Within the file DeviceDriver.c make the following adaptations.

    Remove the AdcWorkerThread() and create instead a UartWokerThread() with the following content:

    static void UartWorkerThread( const void* arg )
    {
      char ch = 0;
    
      while ( DeviceInitialized )
      {
        /* read one characer from the uart */
        ch = EwBspConsoleGetCharacter();
    
        /*
           Important note: This function is a separate thread/task and not executed
           in the context of the main GUI thread/task. NEVER make a direct function
           call to a method of the driver class or any other generated code
           from an interrupt handler or any other thread/task.
           EwInvoke() or EwInvokeCopy() have to be used to schedule the invocation of
           the desired method in the context of the GUI thread/task.
        */
        if ((( ch >= 'A' ) && ( ch <= 'Z' )) || (( ch >= 'a' ) && ( ch <= 'z' ))
          || (( ch >= '0' ) && ( ch <= '9' )) || ( ch == ' ' ))
          EwInvokeCopy( UpdateUartCharProc, &ch, sizeof( char ));
    
        /* sleep for a certain period... */
        EwBspOsDelay( 20 );
      }
    
      /* terminate the worker thread */
      WorkerThread = 0;
      EwBspOsThreadDestroy( EwBspOsThreadGetHandle());
    }
    

    Don't forget to add the following include at the beginning of the file DeviceDriver.c:

    #include "ew_bsp_console.h"
    

    And adapt the following define:

    /*
       In order to ensure that the example code of this module is only compiled
       and linked to the example 'DeviceIntegration', we check for generated defines.
    */
    #if ( defined _ApplicationDeviceClass__TriggerHardButtonEvent_ && defined _ApplicationDeviceClass__UpdateUartChar_ )
      #define DEVICE_INTEGRATION_EXAMPLE
    #endif
    

    Step 2: Within Embedded Wizard Studio, open the example DeviceIntegration, navigate to the class Application::DeviceClass and replace the Property AdcValue by a Property UartChar:

    Step 3: Now, open the class Application::Application and add a new TextView to show your UART characters. Name it to UartText. Remove the Adc PropertyObserver and add a new PropertyObserver for the UART:

    The Property Outlet of the UartCharObserver should refer to ^Application::Device.UartChar to get triggered each time a new character is received. And set the Property OnEvent to the slot method onUartCharEvent which is responsible to add the received string to the text view.

    Now you can try to run that on your target. I hope this brief explanation helps.

    For more details let me recommend to study our online documentation:

    Best regards,

    Manfred

    by
    Hi Manfred,

    Actually it is working but If i send a string, I am just getting one character. But I want full string to be printed on the Display.

    Thanks for your help.
    by

    Hi,

    the interface is just sending one received character after the other.

    In order to build a string, you have to concatenate every received character to the string of already received characters.

    The code snippet in my example shows that.

    Best regards,

    Manfred.

    by
    I want to do uart communication as above, but it says to use workerthread to do uart communication.

    Then EW_USE_OPERATING_SYSTEM == 1 Is it correct to use gui_thread by changing this part to EW_USE_OPERATING_SYSTEM == 0?
    by
    There is a function called AdcWorkerThread() in DeviceDriver.C file. Instead of  AdcWorkerThread(), You need to implement UartWokerThread(). In the above answer, Manfred has given the Code Snippets, follow it step by step. You will get
    by
    Hello, rangsons.

    What if i want to use this out of device driver example?

    What is calling the UartWokerThread()?

    Thanks
    by
    see comment above

    you can help this problem

    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

    ...