Show Posts
Pages: [1]
1  Using Arduino / Interfacing w/ Software on the Computer / How send a request to device? on: March 17, 2011, 04:36:46 am
Hi!

I have device IVTM-7N [1] and Arduino Duemilanove
How send a request from Arduino to device?

Request example: $ 0001 RR 0000 04 AD 0D
[Addr] = 0001, [Cmd] = RR, [DataAddr] = 0000, [DataLen] = 04, [ch] = AD

-------------------------------------
Code:
#include <NewSoftSerial.h>  //Include the NewSoftSerial library to send serial commands to the cellular module.
#include <string.h>         //Used for string manipulations

char incoming_char=0;      //Will hold the incoming character from the Serial Port.

NewSoftSerial cell(2,3);  //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin.

void setup()
{
  //Initialize serial ports for communication.
  Serial.begin(9600);
  cell.begin(9600);
 
  //Let's get started!
  Serial.println("Starting...");
  delay(500); // give the module some thinking time
  cell.println("$ 0001 RR 0000 04 AD 0D");
  delay(500); // give the module some thinking time
  cell.println("$ 0001 RR 0000 04 AD 0D");
}

void loop() {
  //If a character comes in from the cellular module...
  if(cell.available() >0)
  {
    incoming_char=cell.read();    //Get the character from the cellular serial port.
    Serial.print(incoming_char);  //Print the incoming character to the terminal.
  }
  //If a character is coming from the terminal to the Arduino...
  if(Serial.available() >0)
  {
    incoming_char=Serial.read();  //Get the character coming from the terminal
    cell.print(incoming_char);    //Send the character to the cellular module.
  }
}

This is not work(
-------------------------------------------------------

[1] http://translate.google.ru/translate?js=n&prev=_t&hl=ru&ie=UTF-8&layout=2&eotf=1&sl=ru&tl=en&u=http%3A%2F%2Fwww.eksis.ru%2Fosobennosti-primenenija-i-tipovye-reshenija%2Fprotokol-obmena-s-priborami-oao-praktik-nts-i-zao-eksis.html

[~800kb] http://viewkazan.ru/foto/20110317_002.jpg (RS-232 of device)
[~800kb] http://viewkazan.ru/foto/20110317_003.jpg (connect to Arduino)
Pages: [1]