Second time I'm asking the same question with no solution, let me elaborate in other way for clarity.
I wrote an Arduino program which uses two serial ports, one is hardware serial port and other is SoftwareSerial port.
No problem with hardware serial port, the problem is with software serial port.
The software serial port's Tx pin works but Rx pin does not work, i.e. portone.available()
is always zero, nothing in the input buffer of the software serial port.
I'm using Arduino IDE 1.6.12 with an Uno board. Previously I used version 1.6.9 but neither works. Here is the piece of code:
#include <SoftwareSerial.h>
String code = "", customer = "";
bool complete = false;
byte c = 0, j = 0;
char customercode[27];
SoftwareSerial portone(10, 11);
void setup() {
Serial.begin(9600);
portone.begin(115200);
pinMode(10, INPUT);
pinMode(11, OUTPUT);
if (Serial) {
Serial.print("Connecting");
}
}
void loop() {
String copy = "";
char inchar = '0';
if (Serial.available() > 0) {
while (Serial.available()) {
char bytes = (char)Serial.read();
if (bytes == '1' || bytes == '2' || bytes == '3' || bytes == '4' || bytes == '5' || bytes == '6' || bytes == '7' || bytes == '8' || bytes == '9' || bytes == '0' || bytes == '.' || bytes == '-' && bytes != '#') {
customercode[c] = bytes;
c++;
} else if (bytes == '#') {
complete = true;
}
if (c > 12 && bytes != '#') {
code += bytes;
}
}
if (c == 13) {
customer += '+';
for (byte i = 0; i < 12; i++) {
customer += customercode[i];
}
}
}
portone.listen();
if (portone.available() > 0) {
portone.println("AT+CMGF=1");
portone.println("AT+CNMI=2,2,0,0,0");
portone.flush();
while (portone.available()) {
inchar = (char)portone.read();
copy += inchar;
}
delay(1);
Serial.print(copy);
} else if (complete == true && customercode != "" && code != "") {
sending();
}
Serial.print(portone.available());
delay(1000);
}