Discussion of issues related specifically to writing code for native mode devices. This includes ZBasic code as well as assembly language code and C code, both inline and standalone.
I'm getting the following internal error, the test case is provided below.
test28_9_09.c:71: error: expected ';' before '(' token
test28_9_09.c:71: error: expected ';' before '}' token
test28_9_09.c:71: error: expected statement before ')' token
test28_9_09.c:75: error: expected ')' before 'else'
test28_9_09.c:82: error: expected ';' before '}' token
test28_9_09.c:104: error: expected declaration or statement at end of input
test28_9_09.c:97: warning: unused variable 'stringTbl'
Error: one or more errors occurred in the back-end build process for "test28-9-09.zxb"
>Exit code: 1
Declare Sub wait4userInput(byVal str as String) Based wait4userInputAddr
private wait4userInputAddr as Long Attribute(used)
public waiting4UserInput as byte = 0
'~ Called from Menu_imp.c menu definition
public sub SetTime() Attribute(Used)
'~ Procedure for getting key input
waiting4UserInput = 1
'~ 2) register the call back routine
wait4userInputAddr = SetTimeDOIT.CodeAddress
'~ call displayMsg("FMT HH:MM")
'~ call DisplaySetPos(1, 5)
end sub
dim kbReadTask(1 to 260) as Byte
Dim keyVal as UnsignedInteger
Dim keyStr as String
Dim inputStr as String
sub kbRead()
do
'~ keyVal = kb_get()
'~ KeyStr = Chr(kb_decode(keyVal, 0))
KeyStr = "f"
'~ if (menuActive = 1) then
'~ if (waiting4UserInput = 1) then
select case keyVal
case 0 'We have finished, passed keys to waiting sub
Call wait4userInput(inputStr)
waiting4UserInput = 0
inputStr = ""
case else
if (Asc(keyStr) <> 0) then
inputStr = inputStr & keyStr
'~ call showUserKey(keyStr)
'~ call showUserKey(inputStr)
end if
end select
'~ end if
'~ end if
call delay(0.3)
loop
end sub
sub SetTimeDOIT(Byval s as String)
end sub
Sub Main()
callTask kbRead(), kbReadTask
end sub
It looks like the code generation for the C function call with parameters is putting the closing ')' in the wrong place. It should be after the parameters, not after the function name.
I have not found a need for based procedures before. Any reason for making it based?
Using based procedures _ I like to try everything out ... but really I have an LCD and keyboard interface, data can be set via the keyboard at different points within a menu or data display screens, validation is triggered via a generic ENTER key handler which calls back to the registered handler for user input which is set up when the user was initially prompted for question, data, y/n, etc.
A GOOD question, I had to go back and look at the code and see how it worked
ndudman wrote:I'm getting the following internal error...
What version of the compiler are you using? I can reproduce the error with the current release v2.8.7. However, the experimental version v2.8.9 compiles your test case without a problem (other than a warning about indeterminate task stack size).
I wanted to look at the generated make file... I tried the undocumented --diag=x100 which was mentioned about a year ago... but perhaps this is different now, I can't find the make file to see closer to understanding what the problem is.
@echo off
set TARG_BASE=swapper
set TARGET=swapper.bin
set MCU=atmega644p
set F_CPU=14745600
set DEVICE=zx24n
set ZXLIBDIR=C:/Program Files/ZBasic/zxlib
set ZXLIB=%DEVICE%
set LDSCRIPT=%ZXLIBDIR%/zx_avr5.lds
set BFLAGS=-D%DEVICE% -mmcu=%MCU% -I"%ZXLIBDIR%" -I.
set FLAGS=-DF_CPU=%F_CPU%UL %BFLAGS% -gdwarf-2 -Os -Wall -funsigned-char -fpack-struct
set CFLAGS=%FLAGS% -Wstrict-prototypes -std=gnu99 -fgnu89-inline
set LDFLAGS=-mmcu=%MCU% -L"%ZXLIBDIR%" -Wl,-T,"%LDSCRIPT%"
set LDFLAGS=%LDFLAGS% -u rtc_ISR
set LDFLAGS=%LDFLAGS% -u int0_ISR
set LDFLAGS=%LDFLAGS% -u int1_ISR
set LDFLAGS=%LDFLAGS% -u int2_ISR
set LDFLAGS=%LDFLAGS% -u pcint0_ISR
set LDFLAGS=%LDFLAGS% -u pcint1_ISR
set LDFLAGS=%LDFLAGS% -u pcint2_ISR
set LDFLAGS=%LDFLAGS% -u pcint3_ISR
set LDFLAGS=%LDFLAGS% -u anaComp_ISR
set LDFLAGS=%LDFLAGS% -u default_ISR
set LDLIBS=-l%ZXLIB% -lm
set CC=avr-gcc
set AR=avr-ar
set OBJCOPY=avr-objcopy
set NM=avr-nm
set OBJDUMP=avr-objdump
set ECHO=echo
set REMOVE=rm -f
set IFILE=%TARG_BASE%.i1
set EXTOBJ=
set ERRCODE=0
set OBJ=sensors.o LedFlasher.o LCD_4P.o MAX6957.o MAX1202.o guicmd.o myTime.o debug.o Glabals.o DS1305.o swapper.o relay.o I:/source/swapper/ntc_convert.o I:/source/swapper/keyboard.o I:/source/swapper/keymap_hd44780_en.o I:/source/swapper/Menu.o
cd "zxTempDir\swapper"
set CMD=%CC% -c %CFLAGS% sensors.c -o sensors.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %CFLAGS% LedFlasher.c -o LedFlasher.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %CFLAGS% LCD_4P.c -o LCD_4P.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %CFLAGS% MAX6957.c -o MAX6957.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %CFLAGS% MAX1202.c -o MAX1202.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %CFLAGS% guicmd.c -o guicmd.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %CFLAGS% myTime.c -o myTime.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %CFLAGS% debug.c -o debug.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %CFLAGS% Glabals.c -o Glabals.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %CFLAGS% DS1305.c -o DS1305.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %CFLAGS% swapper.c -o swapper.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %CFLAGS% relay.c -o relay.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %CFLAGS% I:/source/swapper/ntc_convert.c -o I:/source/swapper/ntc_convert.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %CFLAGS% I:/source/swapper/keyboard.c -o I:/source/swapper/keyboard.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %CFLAGS% I:/source/swapper/keymap_hd44780_en.c -o I:/source/swapper/keymap_hd44780_en.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %CFLAGS% I:/source/swapper/Menu.c -o I:/source/swapper/Menu.o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %AFLAGS% -o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %AFLAGS% -o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %AFLAGS% -o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
set CMD=%CC% -c %AFLAGS% -o
echo %CMD%
%CMD%
if ERRORLEVEL 1 goto error
I think those I:/ paths need to be quoted ? I did that to the bat file as well as added the avr-gcc to the PATH variable and it worked more, but still was missing something. There are also some blank
With the experiemental version there seems to be a problem with initialised variables, following code, dosn't print 1.0 on the experiemental version (Version 2.8.10)
, but does on my older version (. Version 2.6.12, which I had from when I was last working on the project in the spring)
private lcdUpdateInterval as Single = 1.0 ' in seconds, to update LCD
Sub Main()
Debug.print "debug lcdUpdateInterval=" ; lcdUpdateInterval
End Sub
ndudman wrote:With the experiemental version there seems to be a problem with initialised variables
Thank you for supplying a concise test case. We have confirmed the issue, determined its cause and formulated a solution. Further testing is needed to confirm its efficacy.