serial TX issue
in Propeller 1
Hello everyone,
I have a JDY-40 2.4ghz module. i am having zero luck sending commands to it using the flip but i am receiving "START" from it when i first connect power.
I can communicate with the module perfectly using the arduino terminal, 9600 baud with both NL and CR after sending AT+BAUD command
but i just cant seem to figure out what im missing with the propeller? Thanks in advance for any help.
I have a JDY-40 2.4ghz module. i am having zero luck sending commands to it using the flip but i am receiving "START" from it when i first connect power.
I can communicate with the module perfectly using the arduino terminal, 9600 baud with both NL and CR after sending AT+BAUD command
but i just cant seem to figure out what im missing with the propeller? Thanks in advance for any help.
#include "simpletext.h"
#include "simpletools.h" // Include simple tools
#include "fdserial.h"
fdserial *program;
int m = 0;
//-----------------------------------------------------------------
int main()
{
pause(100);
// RX-TX
program = fdserial_open(0, 2, 0, 9600); // p0-p1 transmit to receiver
pause(100);
print("RUNNING\n");
pause(100);
//dprint(program, 'AT+BAUD'); //change text
//fdserial_txChar(program, "AT+BAUD\r\n"); //Command byte
//dprint(program, "%s%d%d", "AT+BAUD", 13, 10); //change text
//dprint(program, "%s%c%c", "AT+BAUD", 0x0D, 0x0A); //change text
//dprint(program, "AT+BAUD%c%c", 13, 10); //send specific text
//dprint(program, "AT+BAUD%c%c", 0x0D, 0x0A); //send specific text
fdserial_txChar(program, "AT+BAUD"); //Command byte
fdserial_txChar(program, 0x0D); //Command byte
fdserial_txChar(program, 0x0A); //Command byte
while(1)
{
m = fdserial_rxChar(program);
print("m= %c, %d,\n",m, m);
pause(100);
}
int i=0;
for( i=0; i<=17; i++ )
{
m = fdserial_rxChar(program);
print("m= %c, %d,\n",m, m);
pause(100);
}
print("DONE!\n");
}
//---------------------------------------------------------------
Comments
print("RUNNING\n\r");
print("RUNNING\r\n");
I found this on page 4 of the datasheet.
i have tried so many combinations i have lost count. i am also able to send and receive with the propeller using it as just a wireless transmitter, but i can not send to it when i try to program it. if that makes sence?
fdserial_open(0, 2, 0, 9600); // p0-p1 transmit to receiver
This actually defines P2 as the TX pin.inverted serial communication?
program = fdserial_open(0, 2, 1 , 9600);
Ltech, if i invert will that also change the RX? i know i can currentlty receive with (0,2,0,9600)?
Pin 12 needs to be grounded to send AT commands and the commands need to be ended with CR/LF or \r\n
dprint(program, "AT+BAUD\r\n");
Mike
Mike
#include "simpletext.h" #include "simpletools.h" // Include simple tools #include "fdserial.h" // SET pin pulled low to program ID // SET pin pulled high for normal operation fdserial *program; char m = 0; char trash = 0; //----------------------------------------------------------------- int main() { //low(10); pause(100); // RX-TX program = fdserial_open(0, 1, 0, 9600); // p0-p1 transmit to receiver pause(100); print("RUNNING\r\n"); high(7); pause(1000); writeChar(program, 0x41); writeChar(program, 0x54); writeChar(program, 0x2B); writeChar(program, 0x42); writeChar(program, 0x41); writeChar(program, 0x55); writeChar(program, 0x44); writeChar(program, 0x0D); writeChar(program, 0x0A); while(1) { m = fdserial_rxChar(program); print("receive= %c,\n", m); pause(100); } //high(10); print("DONE!\n"); } //---------------------------------------------------------------
I ran across this before.
The fdserial_txChar function is fine and will transmit the characters as is.
Mike
char Data[] = "AT+BAUD\r\n"; for (int i =0;i<strlen(Data);i++) fdserial_txChar(program, Data[i]);
Mike
fdserial_txChar(program, "AT+BAUD"); //Command byte
I think that fdserial_txChar(...) Only writes the single "A" character to the program device... "T+BAUD" just get dropped into the bit bucket. (Just my guess, as you've seemed to have fixed the problem by sending out the characters one at a time).
dgately
JDY-40 PROGRAM (1).c:72:1: error: 'for' loop initial declarations are only allowed in C99 mode
dgately
#include "simpletext.h" #include "simpletools.h" // Include simple tools #include "fdserial.h" // SET pin pulled low to program ID // SET pin pulled high for normal operation //added "-std=c99 " in SimpleIDE's "Other Compiler Options" field. fdserial *program; char m = 0; //int i=0; char baud[] = "AT+BAUD\r\n";//BAUD RATE char rfid[] = "AT+RFID\r\n";//WIRELESS ID char dvid[] = "AT+DVID\r\n";//DEVICE ID char rfc[] = "AT+RFC\r\n";//CHANNEL char powe[] = "AT+POWE\r\n";//TRANSMIT POWER char clss[] = "AT+CLSS\r\n";//MODE //----------------------------------------------------------------- int main() { //low(10); pause(100); // RX-TX program = fdserial_open(0, 1, 0, 9600); // p0-p1 transmit to receiver pause(100); print("RUNNING\r\n"); pause(1000); for (int i = 0;i<strlen(baud);i++) fdserial_txChar(program, baud[i]); while(m != 10) { m = fdserial_rxChar(program); print("%c", m); //pause(100); } m = 0; pause(100); for (int i = 0;i<strlen(rfid);i++) fdserial_txChar(program, rfid[i]); while(m != 10) { m = fdserial_rxChar(program); print("%c", m); //pause(100); } m = 0; pause(100); for (int i = 0;i<strlen(dvid);i++) fdserial_txChar(program, dvid[i]); while(m != 10) { m = fdserial_rxChar(program); print("%c", m); //pause(100); } m = 0; pause(100); for (int i = 0;i<strlen(rfc);i++) fdserial_txChar(program, rfc[i]); while(m != 10) { m = fdserial_rxChar(program); print("%c", m); //pause(100); } m = 0; pause(100); for (int i = 0;i<strlen(powe);i++) fdserial_txChar(program, powe[i]); while(m != 10) { m = fdserial_rxChar(program); print("%c", m); //pause(100); } m = 0; pause(100); for (int i = 0;i<strlen(clss);i++) fdserial_txChar(program, clss[i]); while(m != 10) { m = fdserial_rxChar(program); print("%c", m); //pause(100); } m = 0; pause(100); print("DONE!\n"); } //---------------------------------------------------------------