Pi Folderitem NilObjectException

Hello Everyone,

Is there a limit to the folderitem path length on the Raspberry Pi?

I am wanting to copy a file from a directory to the desktop but the nativepath seems to remove portions of the FolderItem path. Below is a Screen Grab from the Raspberry Pi B 2, where the starting directory is /sys/bus/w1/devices. The program searches for the next subdirectory which begins with the string ‘28-’ and then moves to this directory. This is where the issue happens. The string is correct with the path /sys/bus/w1/devices/28-00000620c1c9, but the folderitem path f = /sys/bu/devices/w1_bus_master1/28-00000620c1c9 is incorrect, as it is missing the s/w1/ portion of the path.

Here is the ‘Pi String’ pushbutton code for this example (sorry for the spaghetti code) :slight_smile:

[code] Dim FString, TempString as String
FString = “/sys/bus/w1/devices”

Dim f as FolderItem
f = New FolderItem(FString, FolderItem.PathTypeShell)
Listbox1.AddRow "f.NativePath = " + f.NativePath
If f <> nil then
if f.Exists then
Listbox1.AddRow "current directory: " + f.NativePath
Dim FCount, i,j as Integer
FCount = f.Count
For i = 1 to FCount
If InStr(f.Item(i).Name, “28-”) > 0 Then
FString = FString + “/” + f.Item(i).Name
f = GetFolderItem(FString)
Listbox1.AddRow "f = " + f.NativePath + ", FString = " + FString
Listbox1.AddRow "TryFolderCount = " + CStr(f.Count)
If f <> nil then
If f.Child(“w1_slave”).Exists then
FString = FString + “/” + “w1_slave”
f = New FolderItem(FString, FolderItem.PathTypeShell)
Listbox1.AddRow "w1_slave exists: " + f.NativePath
Dim MyCopy as FolderItem = SpecialFolder.Desktop
f.CopyFileTo MyCopy
Listbox1.AddRow “The subdirectory does not exist”
End If
Listbox1.AddRow “The subdirectory is nil”
End If
End If
Listbox1.AddRow “The directory does not exist”
End if
Listbox1.AddRow “The directory is nil”
End If[/code]

Here is the download link to the example program: Example9-1b. The Windows code works well, but the ‘Pi String’ pushbutton code does not work.

Thanks for your thoughts and advice.

Try running a ‘cat’ command on the ‘28-******’ object from the shell, see if it contains any content. If it does then it’s a file. That’s if I understood your post correctly.

I have a similar problem with this.
If i remember right the “28-00000620c1c9” is the folder to read temperature device from python script right?
If there is a bad connection the folder “28-” do not exist or is random start number.
To read my temperature sensor i have use the “ds18b20.py” file.But to make it work need to be on home folder or documents…
One solution is to use the shell…
If your problem is similar to this i will post the working example…

Hi Slim,

There is content in this file, which is the 1-wire temperature sensor. The folder is populated, and it just seemed to not work.

Hi Loannis.

I am trying to create a Xojo-only example, and may resort to using python in this one example.

Thanks for the replies Slim and Loannis. I’ll see if I can try a workaround.

The same problem was for me…1-wire k-type sensor.
so i make this example maybe you get idea. link example
The exception you get i think is from permissions…when i try the shell all working fine.