Hey, im trying to read the frequency of my TS-590sg, i've been trying things for like 2 weeks but im unable to communicate through the COM port.
From the examples that i tried it seems that you need to send the command IF; and the radio will response you with the frecuency, so now if i monitor the Seríal am only getting IF; repeating again and again but nothing about what i need.
Actually im using MEGA2560 and TTL-RS232 converter, i've tried from Serial and Serial1, still the same result, RX led is not even blinking...
Heres my code:
int inByte= -1; // incoming byte from serial RX
char buffer[100]; // string for incoming serial data -- a buffer
int bufferPos = 0; // string index counter
void setup() {
Serial.begin(57600); // setup serial speed
}
void loop() {
Serial.flush(); //
Serial.print("IF;");
delay(200);
if (Serial.available() > 0) {
inByte = Serial.read();
read_if();
}
}
void read_if () {
if (inByte == 'I') {
while (bufferPos != 38) {
if (Serial.available() > 0) {
buffer[bufferPos] = inByte;
bufferPos++;
inByte = Serial.read();
if (inByte == ';') break;
}
}
String str_if = buffer;
String qrg ;
qrg = str_if.substring(5,10);
if ((qrg[0] == '0')&&(qrg[1] == '1'))
{
Serial.println("160");
}
if (qrg[1] == '3')
{
Serial.println("80");
}
for (int c = 0; c < bufferPos; c++) {
buffer[c] = 0;
}
bufferPos = 0;
}
}
Hope you guys could help me, thank you in advance