0

I'm trying to read serial data from a unit and print it, over the RX/TX pins into a non PC controller. This is my code I've written, but it doesn't seem to be working. Does anyone have any suggestions?

void keypad(const char *event, const char *data);//forward declaration
String outgoingString;
void setup() {
Serial1.begin(9600, SERIAL_8N2);//begin serial at: 9600baud, 8 data bits, no 
parity, 2 stop bits
Particle.subscribe("Janus485b", keypad, MY_DEVICES);// subscribe to 
secondary publish of data from keypad
}

void loop() {
//read incoming data on serial, and publish back to secondary for keypad
while(Serial1.available() > 0){
String incomingString = Serial1.readStringUntil('\n');
Particle.publish("Janus485a", incomingString, PRIVATE);
Serial1.flush();//wait for serial buffer to empty
}

}
void keypad(const char *event, const char *data) {
//read incoming data from secondary at keypad, write to controller
String outgoingString = ("received value=0x%x", outgoingString);
Serial1.write((uint8_t*)&data, sizeof(data));
Serial1.flush();//wait for serial buffer to empty
}
  • Please take some time to read [the help pages](http://stackoverflow.com/help), especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). Also please [take the tour](http://stackoverflow.com/tour) and [read about how to ask good questions](http://stackoverflow.com/help/how-to-ask). Lastly please learn how to create a [Minimal, Complete, and Verifiable Example](http://stackoverflow.com/help/mcve). – Some programmer dude Mar 23 '18 at 13:46
  • How is it not working? What are the actual output or behavior versus the expected output or behavior? – Thomas Matthews Mar 23 '18 at 14:01
  • When you used the debugger, which statements are causing the issue or are suspect? – Thomas Matthews Mar 23 '18 at 14:02
  • No issue or error is showing in the ide I'm using, the code compiles fine. I'm just not getting any response on the other end. This doesn't help you guys help me, but I was hoping something a little more obvious would stick out to mire experienced programmers. I'll add in some serial print lines and see if I can see anything coming through on a terminal, maybe that can shed more light. – Michael Jones Mar 23 '18 at 14:14

0 Answers0