Hi Dennis, I've been playing with that yesterday. I think the library needs to be changed in a couple of places. As you pointed out, it doesn't really know if the GPIO pin was already exported until it tries to do it and then flags that it's exported in the flags variable.
The problem is if the export fails it then not only checks an invalid flag setting and does the unexport but that ends up removing an exported pin that was already there when the program stops. I don't like that behaviour. I thought I saw that it only changes it to input from output but yet it's gone when the program finishes so that will take some more investigation. What I found yesterday is by adding the delay you suggested down in the library after the TryWriteTextToFile() that I now get run from command line performance. Most of yesterday was a bit of a write-off dealing with a missing SIM card for my wife's new iPhone 12 and some running around to get other problems solved. >From puTTY I reliably get this now. debian@ebb:~/lazarus/pxl/Samples/FreePascal/SingleBoard/Generic/Blinky$ ./Blinky Blinking LED, press any key to exit... debian@ebb:~/lazarus/pxl/Samples/FreePascal/SingleBoard/Generic/Blinky$ Today I want to change that low level code to: 1. Not set the exported flag if the pin is already there so it won't be unexported at the end but only set to what it was before the program ran. This means we also won't try to export it at the start. 2. If it was found to not be there then add the delay but within a repeat until with shorter sleep times and a loop counter. I'll report back when it's done. John > -----Original Message----- > From: [email protected] [mailto:[email protected]] On > Behalf Of Dennis Lee Bieber > Sent: May-13-21 9:04 AM > To: Beagleboard > Subject: [beagleboard] Re: Using GPIOs without Using sudo > > o/~ Talking to myself in public... o/~ > > On Wed, 12 May 2021 17:22:04 -0400, in gmane.comp.hardware.beagleboard.user > Dennis Lee Bieber <[email protected]> > wrote: > > I'd strongly recommend editing this and doing whatever needs to be done > to rebuild the PXL library (if it doesn't just compile from sources > everytime) OR... > > >procedure TSysfsGPIO.ExportPin(const Pin: TPinIdentifier); > >begin > > TryWriteTextToFile(FExportFileName, IntToStr(Pin)); > > Sleep(1000); <<<<< > > > SetPinBit(Pin, ExportedBitmask); > >end; > > ... modifying the source program (for test: Blinky) to explicitly export > pins and delay before trying to do anything with them... > > """ > begin > GPIO := TSysfsGPIO.Create; > > GPIO.ExportPin(PinLED); <<<<<<<< > Sleep(1000); <<<<<<<< > > try > // Switch LED pin for output. > GPIO.PinMode[PinLED] := TPinMode.Output; > > WriteLn('Blinking LED, press any key to exit...'); > """ > > Modifying the library (and fine-tuning the sleep duration to the > minimum that is reliable) should ensure that any implicit pin export works > safely. Modifying the application source, OTOH, means if one exports ALL > NEEDED pins at the start, only one sleep would suffice for the batch, > rather than getting a sleep on each implicit export. > > *** WORRY ABOUT SPI AFTER THE GPIO PROBLEM IS SOLVED *** > > > > -- > Dennis L Bieber > > -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to the Google Groups > "BeagleBoard" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/beagleboard/nriq9ghfakl67f0tdb9mm6qdqriiiundg6%404ax.com. -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/0b0f01d7481a%242b713cf0%248253b6d0%24%40autoartisans.com.
