Prop and the Parallax DataLogger - Issue writing to a text file
What I am trying to do is read from a file (Input.txt). Store the individual Bytes into a free range of RAM. Read from the same region of RAM into a new file text file (Output2.txt). then light up LED's on a board in the order of 1 2 3 ...
This is proof of concept for me before I can write my real program.
My program works, but Section 3 when I write to Output2.txt I get garbage in the file. What am I doing wrong?
Input.txt contains: 123456123456CRLF
Output2.txt contains:
¬#¤ð
¬#¤ð
This is proof of concept for me before I can write my real program.
My program works, but Section 3 when I write to Output2.txt I get garbage in the file. What am I doing wrong?
Input.txt contains: 123456123456CRLF
Output2.txt contains:
¬#¤ð
¬#¤ð
'Section 1 logger.flush logger.changeDirectory(string("\")) IF logger.openFileForRead(string("Input.txt"),0) logger.seek(USBOffset) logger.readFromFileUntilChar(string("Input.txt"),@arrUSBBuffer,CR,@USBOffset) logger.closeFile(string("Input.txt")) lcdout.cls lcdout.str(lcdnum.dec(USBOffset)) WAITCNT((CLKFREQ + 2) + CNT) 'Section 2 Repeat I from 0 to (USBOffset - 1) lcdout.cls WAITCNT(CLKFREQ / 4 + CNT) arrString[0] := arrUSBBuffer[I] IF arrString[0] == CR arrString[0] := 65 ' A lcdout.str(@arrString) Byte[$39D0][I] := arrString[0] 'Write data to region of free memory WAITCNT(CLKFREQ / 4 + CNT) ELSE lcdout.cls lcdout.str(string("Error...", CR)) 'Section 3 IF logger.openFileForWrite(string("Output2.txt"),0) 'logger.writeToFile(string("ABCDE"),5,0) 'Works but not used Repeat I from 0 to (USBOffset - 2) ID := Byte[$39D0][I] 'ID := ID + 48 logger.writeToFile(ID,1,0) logger.closeFile(string("Output2.txt")) ELSE lcdout.cls lcdout.str(string("Error...", CR)) 'Section 4 dira[LEDs_START..LEDs_END]~~ ' Set entire pin group to output Repeat I from 0 to (USBOffset - 2) ID := Byte[$39D0][I] ID := ID - 32 'LED's start at D17 - D25 to compensate -48 (ASCII) + 16 (Target) = D17 outa[ID] ~~ waitcnt(clkfreq + cnt) ' Wait 1 second -> 1 Hz outa[ID] ~
Comments