Shop OBEX P1 Docs P2 Docs Learn Events
fopen not working — Parallax Forums

fopen not working

feilmeierfeilmeier Posts: 2
edited 2013-03-19 15:35 in Propeller 1
Hi,

I just started up on the propeller this last weekend, and when I try to open a Full Duplex Serial Link, my file pointer gets filled with NULL. What is missing, or is it a compiler option that I have missed somewhere?
#include<stdio.h>#include<propeller.h>
#include<cog.h>
#include<errno.h>
#include<driver.h>
int main(void)
{
     FILE* t;
     extern _Driver _FullDuplexSerialDriver;
     _Driver *_driverlist[] = {
     &_FullDuplexSerialDriver,
     NULL
     };
     waitcnt(CLKFREQ+CNT);
     t = fopen("FDS:4800,15,14","r");
     
     if(t == NULL){
          printf("Fatal Error: %d\n",errno);
     }
     else{
          printf("All Okay\n");
     }
     waitcnt(CLKFREQ+CNT);
}

Here is the result I get from errno, which by the looks of the documentation, is file not found.

PropGCC.png
229 x 89 - 4K

Comments

  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-19 15:19
    I think you need to move the _driverlist array out of the function so it will be a global. Otherwise, the filesystem code won't see it and will use a default table.
  • feilmeierfeilmeier Posts: 2
    edited 2013-03-19 15:35
    That fixed it, thanks a bunch.
Sign In or Register to comment.