I am new to arduino I am trying to some something seemingly simple but I need some help
I am basically trying to send commands to a device from the device manual the command should be as follows
MONITOR A: [CR]
Identify: true[CR]
[CR]
The way i understand it is the command wont take until it get the blank CR I am modifying a program I found on the Web, where the guy uses the serial monitor to send a command, I simply added my command string to where he sends the data typed in the serial monitor, that seemed to work albeit i get an error message saying syntax error from the monitor, becasue of the letter i typed on the serial monitor
here is the code
#include <SPI.h>
#include <Ethernet.h>
/**** DEFINITION DES VARIABLES ****/
// Adresse MAC de la carte Ethernet
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x9E, 0x16 };
// Adresse IP de la carte Ethernet si pas DHCP
byte ip[] = { 192,168,0,222 };
// Adresse du chassis SNELL
byte rollcall[] = { 192,168,0,2 };
// Client Ethernet
EthernetClient clientRollCall;
// Varible réception série
String code;
/**** SETUP DU SYSTEME ****/
void setup() {
// Ouvre la connexion série pour la console
Serial.begin(9600);
Serial.println("Connection Serie etablie");
delay(500);
Serial.println("Vitesse du port 9600 bps");
delay(500);
// Connection Ethernet
Ethernet.begin(mac,ip);
delay(500);
Serial.println("Connection IP en cours ...");
delay(1000);
if(clientRollCall.connect(rollcall, 9992 )) {
Serial.println("Connection au chassis SNELL etablie.");
clientRollCall.connect(rollcall, 9992);
delay(100);
clientRollCall.println("MONITOR A:");
delay(100);
clientRollCall.println("Identify: true");
delay(100);
clientRollCall.println();
delay(100);
}
else {
Serial.println("Echec de la connection au chassis SNELL.");
}
}
/**** CONVERSION RS232 > IP ****/
void loop(){
// Lecture des données entrantes sur le port série (Arduino Uno).
// Changer numéro de port si Board différente du UNO.
// Nécessite une interface TLL vers RS232.
if(Serial.available()){
char incomingString = Serial.read();
if (code.equals("none")){
Serial.println("Aucune commande recue");
} else {
Serial.println("Commande recue :"+incomingString);
clientRollCall.connect(rollcall, 9992);
//clientRollCall.stop();
}
delay(100);
}
if(clientRollCall.available()){
char c = clientRollCall.read();
Serial.print(c);
}
while (Serial.available() > 0) {
char inChar = Serial.read();
if (clientRollCall.connected()) {
clientRollCall.print(inChar);
Serial.print(inChar);
clientRollCall.println("MONITOR A:");
clientRollCall.println("Identify: true");
clientRollCall.println("");
}
}
}
so right at the very end the following line
while (Serial.available() > 0) {
char inChar = Serial.read();
if (clientRollCall.connected()) {
clientRollCall.print(inChar);
[code]Serial.print(inChar);
takes what you type and sends it to the monitor, so i tried deleting that line and it doesnt work anymore after some trial and error, it seems that on the bottom corner of the serial monitor you have an option for BOTH NL and CR if thats enabled it works mainly the NL, if i put the
Serial.print(inChar);
it works as long as the NL is enabled so i take it it needs an new line in order for the command to take, how do i do that using the client.print or println command?
Thank you[/code]