Shop OBEX P1 Docs P2 Docs Learn Events
Writing to a file. — Parallax Forums

Writing to a file.

IntaminIntamin Posts: 5
edited 2008-04-18 13:29 in Propeller 1
Hi,

So I'm using the propeller chip to process data, etc, and I was wondering if anyone has a simple example on how to write a variable's stored data to a file.

Say I get the signal strength from an xBee wireless mote every second. How could I take that signal strength variable and write the strength line by line each time I receive a new value?

For example, in Python you open a file:
openedfile = open('newfile','w')             'Where newfile is just a random name

'Then you use Python's file class assigned to every newly opened file...

while 1:
  signal_strength = blah blah blah           'What code is necessary to get the value every second
  openedfile.writeline(signal_strength)
  if not signal_strength:                    'when there's no data left to be acquired, exit
    break



...to write the signal_strength variable on each line of a new file, leaving you with all your signal strengths written on one line after another.

So the idea is to have this file saved in the chip's memory (or wherever) and then I'd come and grab that file somehow at a later time. If this is even possible, how could I do it in Spin?

Thanks a lot!

Post Edited (Intamin) : 4/14/2008 2:01:05 PM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-14 22:08
    Python and other similar languages assume that you have a complete operating systems and specific I/O devices (like a keyboard / display / disk drive). The Propeller has no operating system and really no specific I/O devices. Most systems made with it have an EEPROM for storing the initial program to be run and you can add additional EEPROM easily. The Hydra and the Protoboard come with EEPROMs larger than the minimum of 32K and the extra EEPROM is easily used for storing data. You can also attach an SD card to a couple of I/O pins and manipulate standard Windows files.

    Look in the Propeller Object Exchange for Basic I2C Drivers (for EEPROM use) and for SD Card FAT File System Drivers. Both can be included in your program and they come with examples. Look in the comments.
  • IntaminIntamin Posts: 5
    edited 2008-04-18 13:29
    Thanks, I realized what I was asking after I posted, but this info is good. Appreciate it!
Sign In or Register to comment.