Advertisement
silver2row

.c and ideas...

Mar 13th, 2022
1,126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. // output-example-basic: sysfs-gpio.c:146: gpio_is_output: Assertion `c == 'i' || c == 'o'' failed.
  2. // Aborted
  3.  
  4. // Error from the lib!
  5.  
  6. // Source below:
  7.  
  8. #include "sysfs-gpio.h"
  9. #include <stdio.h>
  10.  
  11. int main()
  12. {
  13.         struct Gpio gpio = GPIO_INITIALIZER;
  14.         gpio_open_output( &gpio, "/sys/class/leds/relay-jp3", 0 );
  15.  
  16.         int const timeout_ms = 3000;  // -1 = no timeout
  17.         gpio_open( &gpio, "/sys/class/leds/relay-jp3", 0 );
  18.         if( gpio_is_output( &gpio ) ) {
  19.                 gpio_write( &gpio, 0 );
  20.         } else {
  21.                 gpio_set_direction_output( &gpio, 1 );
  22.         }
  23.  
  24.         printf( "Print in %d milliseconds.\n ", timeout_ms );
  25.  
  26.         gpio_close( &gpio );
  27.         return 0;
  28. }
  29.  
  30. // I changed some of the source to handle the GPIOs on the am335x to Relays for the RelayCape.
  31.  
  32. Seth
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement