Simple IDE: Running i2c and fdserial in different cogs
Hey everyone,
I'm having an issue with running fdserial and i2c on different cogs. I'm not sure but it seems that declaring fdserial and i2c parameters are not recognized in the cogs. I'm using simple IDE since I'm more comfortable programming in c. Reason why I'm trying in different cogs is because I have several serial devices and i2c devices to read from. Here is my code:
#include "simpletools.h" // Include simple tools #include "fdserial.h" typedef unsigned char byte_t; volatile int n; volatile byte_t val; void readFC(); int main() // Main function { // Add startup code here. int *FScog = cog_run(readFC,128); while(1) { // Add main loop code here. //n = fdserial_rxCount(flysky); //val = fdserial_rxChar(flysky); printf("%d %x\n",n,val); } } void readFC() { fdserial *flysky; flysky = fdserial_open(1,-1,0,115200); while(1) { n = fdserial_rxCount(flysky); val = fdserial_rxChar(flysky); } }
Comments
Here's the thing.
fdserial works by putting itself in a cog to process the serial data in real time. So, putting it in a cog just wastes a cog.
It also looks like you're trying to read a flysky receiver. I have an X8R set for 16 channels and use an SBUS decoder function on the P1 which works great.
Mike
Hey Mike,
Thanks for the response. Yeah I’m using a flysky 10 channel receiver on sbus. I’m trying to read the data from the flysky on a different cog. For example, I want to read fdserial_rxChar in a different cog since I have several tx/rx pins working simultaneously. If you can share me your code that would be awesome!
Chris
I thought all those libraries where in the object exchange but I could not find it.
Anyway, I have them on github here: C Prop libraries
I have a library for driving the ESC's but I don't see it in the list of libraries.
Mike