Shop OBEX P1 Docs P2 Docs Learn Events
PropGCC and C3 — Parallax Forums

PropGCC and C3

I have been making some headway with my C3 experiments, now I have come to problem. I want to implement the SD driver and use FDSerial, this is what I am using:
/* c3xsensor.c */
#include "propeller.h"
#include <sys/rtc.h>
#include "misc.h"
#include "sht11.h"
#include <sys/sd.h>
#include <dirent.h>
#define BUFFERLEN 10
FILE *term;
extern _Driver _FDSerialDriver;
extern _Driver _FileDriver;
_Driver *_driverlist[] = {
 &_FDSerialDriver,
 &_FileDriver,
 NULL
};
    *term = fdserial_open("FDSER",31,30,0,9600);
The serial part is not working, I get an error - incompatible types 'FILE and type int'.  I have not tried the SD part yet. For the SD what is now the correct way for doing this with the C3, does it still need mount()? Again, this all command line approach, no SimpleIDE.
I had to rework Sensirion sht11 code to make it work with a command line approach, at least it is working as expected.
Ray

Comments

  • The C3 has a crazy hookup with a counter and demultilexer to select what spi device to talk to, so standart sd drivers won't work.
  • The C3 has a crazy hookup with a counter and demultilexer to select what spi device to talk to, so standart sd drivers won't work.

    That has been sorted out as of a couple of years ago, I do not remember if you still need to use a mount() function. If I get desperate than I will provide a mount(), but I would like to get the latest info on this.
    The problem I having now is getting a serial to work, so far I have had it compile and then lock up my program after load, or it does not recognize fdserial when compiled.
    Ray

  • David BetzDavid Betz Posts: 14,516
    edited 2015-07-19 22:20
    What is fdserial_open? I don't see that function as part of the PropGCC library. In any case, its name begins with "fd" which says to me that it returns a file descriptor which is an integer. That cannot be assigned to a FILE variable. Even if it is like fopen and returns a file pointer, you would need to remove the * in the assignment statement:
    term = fdserial_open("FDSER",31,30,0,9600);

    However, my guess is it returns and integer and you'd need to do something like this:
    int fd;fd = fdserial_open("FDSER",31,30,0,9600);
  • I remember before simpletools, their was a way of opening up a port with simpleserial, what would be the proper way of doing that. And I also thought, at that time, that their was a way of using fdserial, because it has more powerful commands associated with it? Not sure on these points, hopefully I can get some clarification.
    Ray
  • Dave HeinDave Hein Posts: 6,347
    edited 2015-07-19 23:07
    There is an fdserial_open function in the simple libraries.  It's prototype is
    fdserial * fdserial_open (int rxpin, int txpin, int mode, int baudrate);You would need to include simpletools.h and link to the simple libraries.You can also open a serial port using fopen.  Check the PropGCC documentation on how to do that.EDIT: The documentation for fopen is at http://propgcc.googlecode.com/hg/doc/Library.html#fopen .

  • There is an fdserial_open function in the simple libraries.  It's prototype is
    fdserial * fdserial_open (int rxpin, int txpin, int mode, int baudrate);
    You would need to include simpletools.h and link to the simple libraries.
    You can also open a serial port using fopen.  Check the PropGCC documentation on how to do that.
    EDIT: The documentation for fopen is at http://propgcc.googlecode.com/hg/doc/Library.html#fopen .




    Ah, I guess the "fd" stands for "full duplex" rather than "file descriptor". My mistake. I guess I should stop trying to help out with PropGCC questions because I'm not thaf familiar with the simple libraries and they seem to be all anyone is using these days.
  • There is an fdserial_open function in the simple libraries.  It's prototype is
    fdserial * fdserial_open (int rxpin, int txpin, int mode, int baudrate);
    You would need to include simpletools.h and link to the simple libraries.
    You can also open a serial port using fopen.  Check the PropGCC documentation on how to do that.
    EDIT: The documentation for fopen is at http://propgcc.googlecode.com/hg/doc/Library.html#fopen .




    Ah, I guess the "fd" stands for "full duplex" rather than "file descriptor". My mistake. I guess I should stop trying to help out with PropGCC questions because I'm not thaf familiar with the simple libraries and they seem to be all anyone is using these days.



    The simple libraries are useful, but it does bother me that there are some functions that duplicate the standard functions, and aren't really necessary. One example is the print function, which is basically the same as printf.

    Ray, as far as mount is concerned, I believe it needs to be called explicitly unless you are running the the XMMC model from an SD card. BTW, mount is a simple tools function. However, I'm not sure it will work with the C3 card since mount only allows specifying DO, DI, CLK and CS. I think you need to call dfs_mount for the C3 card. You can look at the filetest demo to see how dfs_mount is called.
  • Thanks Dave and David. The way my experimenting is shaping up is that I now have a misc.c file which is basically a very reduced simpletools.c, for now. I will be creating a miscfdserial.c which will contain the essentials for serial. Some of these will grow in size, but they will be command line useable.
    The SD card thing is very confusing, at the Learn site, their example shows the use of a mount() function, but that is heavy on Activity board functionality. I remember at one point, back a couple of years, their was a discussion about not needing to use the mount() function, this seems to bouncing all over the place.
    I am also noticing that if you will be using a specific type of board, you almost need to have a board specific driver file. So maybe I need to start thinking about that while my support files are still manageable. I have to be very careful, this could turn out to be a bigger project that I want to get involved in.
    Ray
Sign In or Register to comment.