I'm experiencing a strange procedure behaviour (Ubuntu 9.04). Because the build-in serial communication functions don't work(?), I'm trying to use the Linux api's to control the com port with the standard “tcgetattr” function to set the port settings, baud, etc… The code works fine if used outside a procedure, if used inside I get a “Invalid memory access” error on the Endprocedure line.
I was able to reproduce the problem:
Code: Select all
#O_RDWR = 02
#O_NOCTTY = 0400
#O_NONBLOCK = 04000
#O_NDELAY = #O_NONBLOCK
Structure termios
c_iflag.i
c_oflag.i
c_cflag.i
c_lflag.i
c_line.c
c_cc.s{17}
EndStructure
#TestProcedure = 1 ; 0 - 1
Procedure TestCom()
lngCommHandle = open_("/dev/ttyS0", #O_NDELAY | #O_NOCTTY | #O_RDWR , 0)
tcgetattr_(lngCommHandle, @mTer.termios) ;???
MessageRequester("", Str(mTer\c_cflag))
close_(lngCommHandle)
EndProcedure ;Invalid memory access error??????
OpenConsole()
If #TestProcedure
TestCom()
Else
lngCommHandle = open_("/dev/ttyS0", #O_NDELAY | #O_NOCTTY | #O_RDWR , 0)
tcgetattr_(lngCommHandle, @mTer.termios)
MessageRequester("", Str(mTer\c_iflag))
close_(lngCommHandle)
EndIf
Debug "Test"
CloseConsole()
but this was only for imported functions.
Is there some work-around for this problem?



