Difference between revisions of "Example io demo UPDATE 2019"

From wiki.emacinc.com
Jump to: navigation, search
Line 64: Line 64:
 
* Add the Libgpiod_example .c file
 
* Add the Libgpiod_example .c file
 
*repeat same steps as for the .h file, but replace the file name enter Libgpiod_example.c and Copy and paste the following
 
*repeat same steps as for the .h file, but replace the file name enter Libgpiod_example.c and Copy and paste the following
*save the file to add it to your project
+
*select File->Save All
 +
* Open main.c under Libgpiod_example->Sources and copy and paste the following
 +
*select File->Save All, All necessary files have now been added to the project
 +
* Configure build options
 +
*Go to Tools->Options... to open the options window
 +
*Select Devices in the left hand column to open the Devices tab
 +
*From the Devices tab select Devices and Click Add... in the right hand column
 +
*8. Click the '''Add''' button
 +
 
 +
9. Select Generic Linux Device, then click '''Start Wizard'''.
 +
 
 +
[[File:Generic_linux.png|600px|left|thumb|Figure 6: Qt Creator Wizard Selection]]
 +
<br clear=all>
 +
 
 +
10. Type in a name, the IP address, the user name, and the password for the device. Use the credentials below to sign in.
 +
 
 +
{| class="wikitable"
 +
!colspan="2"|Table 4: Default Login Credentials
 +
|-
 +
! Username !! Password
 +
|-
 +
| root || emac_inc
 +
|}
 +
 
 +
[[File:Device_connection.png|600px|left|thumb|Figure 7: Qt Creator Configuration Setup]]
 +
<br clear=all>
 +
 
 +
11. Click '''Next'''.
 +
 
 +
12. Click '''Finish'''.
 +
 
 +
13. A connection will be established with the target device.
 +
 
 +
[[File:Device_test.png|600px|left|thumb|Figure 8: Qt Creator Device Test]]
 +
<br clear=all>
 +
 
 +
14. Click '''Close'''.
 +
 
 +
15. Click '''Apply'''.
 +
 
 +
16. Navigate to the '''Projects''' tab. Here, Qt Creator will ask you to select which kits you will be using with the project. For this example,  we made sure the '''arm''' kit was selected. Then click '''Configure Project'''.
 +
 
 +
[[File:Configproject.png|600px|left|thumb|Figure 9: Configureing Qt Project]]
 +
<br clear=all>
 +
 
 +
17. Now, on the left side of Qt Creator, you will see the project icon, which looks like a monitor. Click this and make sure '''Arm''' is selected under '''Kit''', '''Default''' is selected under '''Build''', and the project is set to be run on the remote device under '''Run'''.
 +
 
 +
[[File:Kitselection.png|600px|left|thumb|Figure 10: Selecting Qt Kit]]
 +
<br clear=all>
 +
 
 +
18. Now, simply press the green play button. The program should run on the target device and yield an output.
 +
 
 +
[[File:Qtoutput.png|900px|left|thumb|Figure 11: Successfully running Qt Project]]
 +
<br clear=all>
 +
 
 
</cl>
 
</cl>

Revision as of 12:27, 3 July 2019

TODO: {{#todo:SEOKWREV (01.03.14-16:47->JG+);(01.03.14-17:35->MD+);(04.07.14-09:45->BS+);(04.09.14-16:15->BS+)|Jgreene|oe 4,oe 5,jg,md,SEOKWREV,ky,bs}}

This demo covers basic GPIO usage for the IPAC single board computer, and 150 and 200 series carrier boards. This demo first cover GPIO manipulation through the Linux terminal and then demonstrates gpio usage in a C program using an io example program.

Hardware Requirements

To use the io demo program you will need the following target hardware.

  • An EMAC 150 series carrier board with a compatible SoM

OR

  • An EMAC 200 series carrier board with a compatible SoM

OR

  • an IPAC

AND

  • additional components to establish to serial and Ethernet connections for your target hardware

Software Requirments

These tools should already be installed if you installed the EMAC SDK using the automatic installer.

Setup

If you haven't already, please review the EMAC_OE_SDK "getting started" page. EMAC_OE_SDK will need to be installed and serial and network connections will need to be established between the developer machine and the target device.See the Serial Connections or Network Connections page for more information on how to connect to the target EMAC product using a serial port or Ethernet connection.

GPIO manipulation through Linux Terminal

GPIOs can be manipulated directly through the target devices serial terminal.

GPIO manipulation in C

A more common manipulation of GPIOs is through a C program. The following example will demonstrated GPIO manipulation using the Libgpiod libary.

On the target device:

  1. Login

  2. Change the file to read write if required

  1. Open qt Creator

  2. Create a new project

    • select '+ New Project' on the 'Welcome' window, the New Project window will appear.
    • Under Projects select Non-Qt Project, Under the middle window select Plain C Application, Click 'Choose...', The Location window will appear.
    • Give your project a name, and choose a Create-in location, Click Next > to advance to the Build System window.
    • On the Build System Window choose either the qmake or cmake option (both will be covered in this tutorial), Click Next > to advance to the Kits window.
    • On the Kits window check only ARM Qt5, Click Next > to advance to the Summary window
    • The options on the Summary window will default to <None>, Click Finish. Your Project will now be generated.
  3. Depending on whether you selected the qmake or cmake option the build files (project_name.pro and CMakeLists.txt respectively) will need to be configured.

    • For the qmake option copy and paste the following into your .pro file.
    • For the cmake option copy and paste the following into your CMakeLists.txt file.
  4. Add the Libgpiod_example .h file

    • With you project selected, click File->New Fileor Project, the New File or Project window will appear.
    • Under Files and Classes select General, and in the middle column select Empty file, Click Choose..., The Location window will appear
    • Name the file Libgpiod_example.h and use the default Path, Click Next> to advance to the Summary window
    • Click Finish, the file will now open.
    • Copy and paste the following into Libgpiod_example.h file
    • Save the file, by click File->Save All, the file will now be added to your project under Libgpiod_example->Headers
  5. Add the Libgpiod_example .c file

    • repeat same steps as for the .h file, but replace the file name enter Libgpiod_example.c and Copy and paste the following
    • select File->Save All
  6. Open main.c under Libgpiod_example->Sources and copy and paste the following

    • select File->Save All, All necessary files have now been added to the project
  7. Configure build options

    • Go to Tools->Options... to open the options window
    • Select Devices in the left hand column to open the Devices tab
    • From the Devices tab select Devices and Click Add... in the right hand column
    • 8. Click the Add button

    9. Select Generic Linux Device, then click Start Wizard.

    Figure 6: Qt Creator Wizard Selection


    10. Type in a name, the IP address, the user name, and the password for the device. Use the credentials below to sign in.

    Table 4: Default Login Credentials
    Username Password
    root emac_inc
    Figure 7: Qt Creator Configuration Setup


    11. Click Next.

    12. Click Finish.

    13. A connection will be established with the target device.

    Figure 8: Qt Creator Device Test


    14. Click Close.

    15. Click Apply.

    16. Navigate to the Projects tab. Here, Qt Creator will ask you to select which kits you will be using with the project. For this example, we made sure the arm kit was selected. Then click Configure Project.

    Figure 9: Configureing Qt Project


    17. Now, on the left side of Qt Creator, you will see the project icon, which looks like a monitor. Click this and make sure Arm is selected under Kit, Default is selected under Build, and the project is set to be run on the remote device under Run.

    Figure 10: Selecting Qt Kit


    18. Now, simply press the green play button. The program should run on the target device and yield an output.

    Figure 11: Successfully running Qt Project