fsrw 'opendir' ?
The problem, at least it is not as expected, is occurring in PUB xbeeTerm, specifically how 'dir' is being shown on the terminal screen. I have the same code for 'dir' in PUB Main, and that seems to be working as expected. In the xbeeTerm, when I run 'dir', the directory listing is all on one line, even though I have a CR implemented to show the directory listing is on its own line. This must be another one of my rookie mistakes that I cannot figure out.
Any ideas for code reduction as it concerns the menu items in the DAT section? It seems that I have to duplicate the items so each item is going to the correct terminal screen.
Thanks
Ray
Any ideas for code reduction as it concerns the menu items in the DAT section? It seems that I have to duplicate the items so each item is going to the correct terminal screen.
Thanks
Ray
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' PboeBase.spin
''
'' July 28, 2013
''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
term : "Extended_FDSerial" '' An enhanced version of (FDS)
xbee : "Extended_FDSerial" ''
misc : "tools" '' My object that contains some common tools.
sdfat : "sd_api"
tusd : "fsrw"
VAR
long xbeeStack[60] '' Most of the time 10 would suffice.
byte tbuf[20]
long mounted
PUB Start
Cogxbee := cognew(xbeeTerm, @xbeeStack)
misc.waitMS(250)
term.Start(31,30,0,115200)
misc.waitMS(250)
term.str(string("Mounting uSD card.",13,10))
if (sdfat.mount_sd == false)
term.str(string("SD not mounted",13,10))
mounted := false
else
term.str(string("SD Mounted.",13,10))
mounted := true
Main
'' To be used as local access for maintenance??
PUB Main | inSbyte, inAbyte
repeat
inSbyte := term.Rx
if inSbyte == 13
term.str(string("This is the BASE unit.",13,10))
repeat
term.Tx("#")
term.RxStr(@TinStrg)
if strcomp(@TinStrg, @stopProg)
term.str(@TinStrg)
CRLF
term.str(string("Program Stopped!",13,10))
cogstop(Cogxbee)
abort
elseif strcomp(@TinStrg, @Tmenu)
term.str(@TinStrg)
CRLF
TmainMenu
elseif strcomp(@TinStrg, @Tmount)
term.str(@TinStrg)
CRLF
if (mounted == false)
sdfat.mount_sd
term.str(string("SD Mounted.",13,10))
mounted := true
else
term.str(string("SD already mounted.",13,10))
elseif strcomp(@TinStrg, @Tumount)
term.str(@TinStrg)
CRLF
sdfat.unmount_sd
mounted := false
term.str(string("SD unmounted.",13,10))
elseif strcomp(@TinStrg, @Tdir)
term.str(@Tinstrg)
CRLF
if (mounted == false)
term.str(string("SD not mounted",13,10))
else
tusd.opendir
repeat while 0 == tusd.nextfile(@tbuf)
term.str(@tbuf)
CRLF
term.str(string("That's the dir",13,10))
else
term.str(string("Invalid Command!",13,10))
'' To be used as actual program usage.
PUB xbeeTerm | inSbyte, inAbyte
'' Rx Tx Mode BAUD
xbee.Start(15,14,0,9600)
repeat
inSbyte := xbee.Rx
if inSbyte == 13
xbee.str(string("This is the air BASE unit.",13,10))
repeat
xbee.Tx(">")
xbee.RxStr(@XinStrg)
if strcomp(@XinStrg, @XonLED) '' For program testing
misc.high(26)
'CRLF
elseif strcomp(@XinStrg, @XoffLED) '' For program testing
misc.low(26)
'CRLF
elseif strcomp(@XinStrg, @Xmenu)
'CRLF
XmainMenu
elseif strcomp(@XinStrg, @Xdir)
if (mounted == false)
xbee.str(string("SD not mounted",13,10))
else
tusd.opendir
repeat while 0 == tusd.nextfile(@tbuf)
xbee.str(@tbuf)
xbee.Tx(10)
xbee.Tx(13)
xbee.str(string(13,10,"That's the dir",13,10))
else
xbee.str(string("Invalid Command!",13,10))
PUB TmainMenu
term.str(string("Menu: menu - this menu, Quit - end program",13,10))
term.str(string(" dir - SD directory, mount - uSD, unmount - uSD",13,10))
PUB XmainMenu
xbee.str(string("Menu: menu - this menu, dir - SD directory ",13,10))
xbee.str(string(" onLED, offLED ",13,10))
PUB CRLF
term.Tx(13) '' CR
term.Tx(10) '' LF
DAT
XinStrg byte " ",0
XonLED byte "onLED",0
XoffLED byte "offLED",0
Xmenu byte "menu",0
Xdir byte "dir",0
TinStrg byte " ",0
TonLED byte "onLED",0
ToffLED byte "offLED",0
Tmenu byte "menu",0
Tdir byte "dir",0
Tmount byte "mount",0
Tumount byte "unmount",0
stopProg byte "Quit",0
Cogxbee byte '' Capture ID of started Cog.

Comments
xbee.Tx(13) xbee.Tx(10)instead of:xbee.Tx(10) xbee.Tx(13)I was scratching my head for hours trying to figure that one out, luckily my program is not a thousand lines of code, yet.Ray