B4J Question Problem compiling Non-UI jar

walterf25

Expert
Licensed User
Longtime User
Hello all, I just started seeing the following issue while trying to work with B4J and a raspberry pi.

Basically I'm trying to talk to a 433 MHz Transceiver over SPI using the raspberry pi 3 B+, everything was working fine up until I decided to make all my functions to return a resumablesub

I am not getting the following error every time I try to compile either in Debug or Release mode

System.UnauthorizedAccessException: Access to the path 'C:\Users\walter.flores\Documents\B4J\B4J Projects\ReceiverSPI\Objects\bin\classes\com\genesis\receiver\cc1101$ResumableSub_getMarcState.class' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at fa.a.ad()
And here is the getMarcState function
getMarcState Function:
Public Sub getMarcState As ResumableSub
    Dim rs As ResumableSub = readStatusReg(CC1101_MARCSTATE)
    wait for (rs) Complete (result As Byte)
    Return Bit.And(result, 0x1F)
End Sub

And Here's is also the readStatusReg function
readStatusReg:
Public Sub readStatusReg(regAddr As Byte) As ResumableSub
    Dim rs As ResumableSub = readReg(regAddr, CC1101_STATUS_REGISTER)
    wait for(rs) Complete (ret As Byte)
    Log("readstatusreg response: " & ret)
    Return ret
End Sub

As I mentioned above, everything was running fine until I had to make all my functions to return a resumablesub.

Any ideas why this is happening?

Walter
 

walterf25

Expert
Licensed User
Longtime User
Something prevents the IDE from accessing the mentioned folder. Might be an anti-virus.
First step is to restart the PC. Maybe there is a locked file.
Hi Erel, thanks for the suggestion, I forgot to mention I actually already tried that and did not change anything at all, what I ended up doing is converting all my functions back to return normal types instead of Resumable subs that worked great, I think there's is bug and I'm running on the latest version of B4J.

Regards,
Walter
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
I don't think that it is a bug. All developers use resumable subs and you are the only one to report it.

I still think that it is related to your anti-virus.
Hi Erel, why would my antivirus allow me to compile the same app without any resumable subs, but won't allow me to compile when I add resumable sub, am I missing something?

Walter
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
I never tried return Byte or Byte() with ResumableSub. Normally my ResumableSubs return String or Boolean. Have you tried compile the jar which return String?
I don't think the return type matters, but I Will try to return either a string or a Boolean, im positive that won't be a problem.
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
So, I have an update, I Added the following function in my class, and I am seeing again the same error

setReceive Function:
Sub Receive
    Dim marcstate As Byte
    setIdleState
    writeStrobe(CC1101_SRX)
    marcstate = 0xFF
    Do While marcstate <> 0x0D
        marcstate = Bit.And(readReg(CC1101_MARCSTATE), 0x1F)
    Loop
    Sleep(100)
    Log("set receiving...")
End Sub

The issue is that as soon as I add the code
Sleep(100)
The function becomes a Resumable sub, when I try to compile the code, I immediately receive the error above.
Why is that, but If I remove the
Sleep(100)
then the code compiles just fine, what is going on?
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
That problematic file is only generated when your Sub getMarcState is declared as a resumable sub. Something then appears to be locking it Have you tried locating the project elsewhere and not in your Documents folder? Do you have some automatic backup program running on that folder like OneDrive?

Like Erel I am sure that this is not a bug in B4J, it is a file access problem unique to your computer.
 
Upvote 0
Top