Shop OBEX P1 Docs P2 Docs Learn Events
problem wit command FILE — Parallax Forums

problem wit command FILE

ingbakeringbaker Posts: 10
edited 2009-08-05 20:21 in Propeller 1
Good morning

With respect to the propeller, I want to load binary data file
into memory, and then I display these datas on the serial terminal.

Here I use the command "FILE", my problem is that it only sends to the terminal from
3rd byte from the file.


This is the program that I use:


CON

_CLKMODE = XTAL1 + PLL16X

_XINFREQ = 5_000_000

OBJ

PANTALLA:"FullDuple xSerial"

VAR

BYTE DATAS

PUB GETDATA | INDEX

INDEX:=0

PANTALLA.START( 31, 30, 0, 57600)

WAITCNT((CLKFREQ* 3)+CNT)

REPEAT

DATAS:=BYTE[noparse][[/noparse] DTFILE][noparse][[/noparse]INDEX]

IF DATAS <> 0

PANTALLA.DEC( DATAS)

PANTALLA.STR( STRING(" "))

PANTALLA.TX( DATAS)

PANTALLA.STR( STRING(" "))

PANTALLA.DEC( INDEX)

PANTALLA.STR( STRING(" "))

PANTALLA.HEX( INDEX,2)

PANTALLA.STR( string(13) )

WAITCNT((CLKFREQ/ 4)+CNT)

++iNDEX

WHILE DATAS > 0

DAT

STR BYTE "Esto es un mensaje",0

DTFILE FILE "DATAFILE.bin"

Now if my DATAFILE.bin has:”12345678….”
With index=0, My program reads 345678… and this losts 1 and 2
But when I replace

DATAS:=BYTE[noparse][[/noparse] DTFILE][noparse][[/noparse]INDEX]

by

DATAS:=BYTE[noparse][[/noparse] DTFILE][noparse][[/noparse]INDEX- 2]


I read from the 1st byte of the file:
With index =0 this is reads 12345678.. and can read all file


Please what happen?
Baker Carpio

Comments

  • AleAle Posts: 2,363
    edited 2009-08-05 14:48
    Try to use the '@' operator to get the address of DTFILE:

    datas := byte[noparse][[/noparse]@DFILE][noparse][[/noparse]index]

    btw: Use the [noparse][[/noparse] code ] and [noparse][[/noparse] /code ] (without spaces) to format your code so it is more legible.

    From your program I assume you speak spanish... Bienvenido aunque ya hayas escrito 5 veces smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Visit some of my articles at Propeller Wiki:
    MATH on the propeller propeller.wikispaces.com/MATH
    pPropQL: propeller.wikispaces.com/pPropQL
    pPropQL020: propeller.wikispaces.com/pPropQL020
    OMU for the pPropQL/020 propeller.wikispaces.com/OMU
  • ingbakeringbaker Posts: 10
    edited 2009-08-05 16:07
    Gracias Ale,
    Esta noche probare tu consejo.
    Saludos
  • AribaAriba Posts: 2,690
    edited 2009-08-05 20:21
    The FILE command automatically generates a byte array, so you can access the data with:

    datas := DTFILE[noparse][[/noparse]index]


    Arriba
Sign In or Register to comment.