I'm not seeing simple_cat and simple_ls examples in the new release.
When I try to compile the versions I have I get this kind of warning message:
C:/FlexSpin/include/filesys/fatfs/ff.cc:6959: warning: Bad number of parameters in call to f_opendir: expected 2 found 3
Did something change with FatFs support?
No, I just added a warning and it is correctly pointing out that there's an extraneous ",0" on line 6959 of ff.cc (which has probably always been there). You can ignore the warning, or if you'd prefer you can remove that extra 0 parameter from the ff.cc source code.
FlexProp is what he renamed FlexGui to. Then there is FlexC, FlexSpin, FlexBASIC that are all compiled with spin2cpp variants (flexspin and flexcc). I think flexspin.exe and flexcc.exe are the same compiler, but flexcc has different message outputs (and maybe command line options?) to better work with IDEs/etc. that can talk to gcc/etc.
Yes, the command line options for flexcc and flexspin are different -- flexcc takes gcc like arguments, and flexspin takes openspin like arguments. Otherwise they're the same compiler.
Can I add in a "#pragma spin" line in my C code and start typing in Spin?
FlexProp is what he renamed FlexGui to. Then there is FlexC, FlexSpin, FlexBASIC that are all compiled with spin2cpp variants (flexspin and flexcc). I think flexspin.exe and flexcc.exe are the same compiler, but flexcc has different message outputs (and maybe command line options?) to better work with IDEs/etc. that can talk to gcc/etc.
Yes, the command line options for flexcc and flexspin are different -- flexcc takes gcc like arguments, and flexspin takes openspin like arguments. Otherwise they're the same compiler.
Can I add in a "#pragma spin" line in my C code and start typing in Spin?
No, no mixing of languages within the same file -- except for PASM, that you can put inside anything else. But you can compile a .spin file with flexcc, or a .c file with flexspin, no problem. The language is determined by the file extension. Someday I should probably implement the "-x language" switch for flexcc, but it seems like a low priority.
FlexProp is what he renamed FlexGui to. Then there is FlexC, FlexSpin, FlexBASIC that are all compiled with spin2cpp variants (flexspin and flexcc). I think flexspin.exe and flexcc.exe are the same compiler, but flexcc has different message outputs (and maybe command line options?) to better work with IDEs/etc. that can talk to gcc/etc.
Yes, the command line options for flexcc and flexspin are different -- flexcc takes gcc like arguments, and flexspin takes openspin like arguments. Otherwise they're the same compiler.
Can I add in a "#pragma spin" line in my C code and start typing in Spin?
No, no mixing of languages within the same file -- except for PASM, that you can put inside anything else. But you can compile a .spin file with flexcc, or a .c file with flexspin, no problem. The language is determined by the file extension. Someday I should probably implement the "-x language" switch for flexcc, but it seems like a low priority.
Yeah, I knew that. I was just giving you a hard time. That certainly wasn't justified though given all of your great work on these tools. My only defense is that I ended my post with a smiley face.
Similar to Rayman's question I have a warning involving "bad number of parameters". What am I doing incorrectly? The program runs correctly and I also was getting the warning when using the ff.c referenced above, I edited line 6959 if ff.c and that does get rid of the warning. Is my syntax wrong somehow?
Warning
C:/flexprop/DEV/ign2020/ign2020.c:97: warning: Bad number of parameters in call to decode_cog: expected 0 found 1
Here's Line 97
printf("decode_cog running on cog %d\n",cogstart(decode_cog, NULL, decode_stack, sizeof(decode_stack)));
EDIT:
I edited the code to use the builtin version of cogstart and now no warnings.
printf("decode_cog running on cog %d\n",__builtin_cogstart(decode_cog, &decode_stack[0]));
I'm sure I just didn't understand the syntax for the macro version, cogstart.
EDIT #2: After grepping for the pertinent macros I found I was using propeller.h and not propeller2.h. Please disregard.
@iseries , C is able to return structures. However, I hardly ever use that feature. I normally used structure pointers for calling and returning values.
@Rayman , I'm not familiar with using the construct "typedef struct Line Line", but I compiled your code in GCC, and it compiled OK, but with a few warnings.
Instead of
typedef struct Line Line;
struct Line {
char* s; /* string content */
size_t l; /* length excluding \0 */
size_t v; /* visual length */
size_t m; /* multiples of LINSIZ? */
Line* p; /* previous line */
Line* n; /* next line */
};
I would write it as
typedef struct LineS {
char* s; /* string content */
size_t l; /* length excluding \0 */
size_t v; /* visual length */
size_t m; /* multiples of LINSIZ? */
struct LineS* p; /* previous line */
struct LineS* n; /* next line */
} LineT;
FlexProp may be having trouble with the way you coded it even though it appears to be valid C.
I think I'm seeing an issue with a function that returns a structure... Is returning a structure like this supposed to work?
Position px=insertstr(p, buf);
Yes, that is supposed to work. Obviously there's a bug somewhere .
A more common idiom in C is to pass a pointer to a structure and manipulate the structure using the pointer, rather than passing the whole struct and then returning it. But struct passing and return is supposed to work, so I'll try to track this down. Thanks for the bug report!
I know that it's not your code, but, now that the WX Module adapter is available for the P2 Edge, mini-Edge, and ES boards, could you add the WiFi port features of proploader to loadp2? Specificially, this would include options -i -n -W as well as supporting Telnet for terminal connections.
On the WX module there is firmware that helps load the bootstrap code onto the P1. From there it uses telnet to load the code on to it.
For the P2 no firmware code is needed as the load process is much simpler. Only a telnet connection is need to load the bootstrap program and then the code. The problem is then that a reset is needed to get the P2 into bootstrap mode.
I guess there could be firmware code added to the WX module that would load a default P2 bootstrap program. Then the load program could take over after that with a telnet connection.
On the WX module there is firmware that helps load the bootstrap code onto the P1. From there it uses telnet to load the code on to it.
For the P2 no firmware code is needed as the load process is much simpler. Only a telnet connection is need to load the bootstrap program and then the code. The problem is then that a reset is needed to get the P2 into bootstrap mode.
I guess there could be firmware code added to the WX module that would load a default P2 bootstrap program. Then the load program could take over after that with a telnet connection.
I know that it's not your code, but, now that the WX Module adapter is available for the P2 Edge, mini-Edge, and ES boards, could you add the WiFi port features of proploader to loadp2? Specificially, this would include options -i -n -W as well as supporting Telnet for terminal connections.
I don't have the hardware yet, although I may order a WX adapter. It sounds like some work is required to adapt the firmware for use with the P2. I hope someone with more experience with the WX might be able to help with this...
@ersmith The "5.0.1" release on github (found here: https://github.com/totalspectrum/flexprop/releases/tag/v5.0.1) reports in both the TCL editor Help->About menu, and in the compiler output, as "5.0.1-Beta". The docs however show 5.0.1 (no "beta").
Complier output:
"d:/Flex2Gui/flexgui/bin/flexspin" -2 -l -D_BAUD=230400 -O2 -Wall -I "d:/Flex2Gui/flexgui/include" "d:/Flex2Gui/flexgui/P2 Libs/datetest.bas"
Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2020 Total Spectrum Software Inc.
Version 5.0.1-beta-v5.0.0-11-g15693cbc Compiled on: Nov 25 2020
I'm putting this out here because it's possible you unwittingly recycled the beta version of the compiler instead of producing the new version. Either that, or I'm being really obtuse again...
Is there a way to change the default baudrate for stdio? Also, is it possible to get the serial output to work with putty or teraterm? You'd think that'd be easy, but I can't make it work for some reason...
Ok, I found how to change the baud... Is this in the docs? Found it in mandelbrot example...
_setbaud(_BAUD);
Update: Figured out that putty and teraterm reset the P2 on connection. Had to flash the program to get it to work with these...
I don't think it's the terminal program doing the echoing... I think the Prop is echoing back what getchar() receives. But, I might be wrong...
Update: I check again and I think I am seeing this right... Was able to sorta fix it by putting "putchar('\b');" after the getchar(). But, I'm not 100% sure that's a good way.
I switched to "jm_serial.spin2" for serial and that seems to do what I need.
Try adding the line "_setrxtxflags(_getrxtxflags() & ~TTY_FLAG_ECHO);". This will clear the echo flag. You will also need to include sys/ioctl.h.
EDIT: There is also a flag TTY_FLAG_CRNL defined in ioctl.h. After startup, _getrxtxflags() returns a value of 3, which indicates that both the echo and the CRNL flag bits are set. I believe the CRNL flag causes both a CR and NL to be sent when calling putchar('\r'). If you want raw output you would need to turn off this flag also.
IDK how that ever would work like that. It indexes into an uninitialized pointer. Would work if p was initialized to zero. Also, the parameter needs to be 32 bit on P2, doesn't it. Infact, why is it passing addresses in integers, aaaaaaaaaaaa?
@"Dave Hein" Yes, just tried it. Thanks, that does make it work better. It stops the echo.
But, the program still doesn't work exactly right...
See the screenshot. There's a funny character in the top left corner that messes up the alignment of the first row.
Also, when I move downward past the end with arrows, all the line numbers should increment, but they don't only the last row is correct.
I looks like getchar() causes an echo of anything typed to the terminal, is this right? Can that be turned off?
All special processing may be disabled by _setrxtxflags(0). _setrxtxflags(m) enables various special handling based on the value of m. If bit 0 of m is set, then echo is enabled. If bit 1 is set, then carriage return is converted to line feed on input, and a carriage return is output whenever line feed is seen.
The current state of the flags may be fetched via _getrxtxflags().
p is uninitialized, so the behavior is undefined; it's fetching data from some random address. If it works on Arduino it does so by accident. If you set p=0 before the return p[address] then it should work.
Comments
No, I just added a warning and it is correctly pointing out that there's an extraneous ",0" on line 6959 of ff.cc (which has probably always been there). You can ignore the warning, or if you'd prefer you can remove that extra 0 parameter from the ff.cc source code.
No, no mixing of languages within the same file -- except for PASM, that you can put inside anything else. But you can compile a .spin file with flexcc, or a .c file with flexspin, no problem. The language is determined by the file extension. Someday I should probably implement the "-x language" switch for flexcc, but it seems like a low priority.
The symptom is that this line somehow calls the insertstr function twice (If I'm seeing it right).
I copied enough of this into simple_ls.c to reproduce this in the attached.
Warning Here's Line 97 EDIT:
I edited the code to use the builtin version of cogstart and now no warnings. I'm sure I just didn't understand the syntax for the macro version, cogstart.
EDIT #2: After grepping for the pertinent macros I found I was using propeller.h and not propeller2.h. Please disregard.
As far as I know C does not return structures. Only pointers to a structure.
Mike
@Rayman , I'm not familiar with using the construct "typedef struct Line Line", but I compiled your code in GCC, and it compiled OK, but with a few warnings.
Instead of I would write it as FlexProp may be having trouble with the way you coded it even though it appears to be valid C.
Yes, that is supposed to work. Obviously there's a bug somewhere .
A more common idiom in C is to pass a pointer to a structure and manipulate the structure using the pointer, rather than passing the whole struct and then returning it. But struct passing and return is supposed to work, so I'll try to track this down. Thanks for the bug report!
I see David Betz wrote it. I think Dave Hein started from pieces of David's code when writing loadp2.
For the P2 no firmware code is needed as the load process is much simpler. Only a telnet connection is need to load the bootstrap program and then the code. The problem is then that a reset is needed to get the P2 into bootstrap mode.
I guess there could be firmware code added to the WX module that would load a default P2 bootstrap program. Then the load program could take over after that with a telnet connection.
Mike
I don't have the hardware yet, although I may order a WX adapter. It sounds like some work is required to adapt the firmware for use with the P2. I hope someone with more experience with the WX might be able to help with this...
Complier output: I'm putting this out here because it's possible you unwittingly recycled the beta version of the compiler instead of producing the new version. Either that, or I'm being really obtuse again...
Regardless, it's working fine for me so far!
Ok, I found how to change the baud... Is this in the docs? Found it in mandelbrot example...
Update: Figured out that putty and teraterm reset the P2 on connection. Had to flash the program to get it to work with these...
Update: I check again and I think I am seeing this right... Was able to sorta fix it by putting "putchar('\b');" after the getchar(). But, I'm not 100% sure that's a good way.
I switched to "jm_serial.spin2" for serial and that seems to do what I need.
But, shouldn't it work? Seems like maybe it should...
I fixed it with this:
EDIT: There is also a flag TTY_FLAG_CRNL defined in ioctl.h. After startup, _getrxtxflags() returns a value of 3, which indicates that both the echo and the CRNL flag bits are set. I believe the CRNL flag causes both a CR and NL to be sent when calling putchar('\r'). If you want raw output you would need to turn off this flag also.
IDK how that ever would work like that. It indexes into an uninitialized pointer. Would work if p was initialized to zero. Also, the parameter needs to be 32 bit on P2, doesn't it. Infact, why is it passing addresses in integers, aaaaaaaaaaaa?
But, the program still doesn't work exactly right...
See the screenshot. There's a funny character in the top left corner that messes up the alignment of the first row.
Also, when I move downward past the end with arrows, all the line numbers should increment, but they don't only the last row is correct.
All special processing may be disabled by _setrxtxflags(0). _setrxtxflags(m) enables various special handling based on the value of m. If bit 0 of m is set, then echo is enabled. If bit 1 is set, then carriage return is converted to line feed on input, and a carriage return is output whenever line feed is seen.
The current state of the flags may be fetched via _getrxtxflags().
p is uninitialized, so the behavior is undefined; it's fetching data from some random address. If it works on Arduino it does so by accident. If you set p=0 before the return p[address] then it should work.