Pages: [1] 2   Go Down
Author Topic: HarwareSerial.h  (Read 2709 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Somebody mail me the library file HardwareSerial.h (including HardwareSerial.h,HardwareSerial.cpp & keyword.txt).
bhairumaaman@gmail.com
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 220
Posts: 13836
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

it is in the c:\program files\arduino\... folder -> search the filesystem from that folder
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why ?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@ tuxduino: I need to collect the serial data from the UART directly to a variable, through a software serial port. To do that, i found that the library HardwareSerial.h contains a function UART.Read(), which very well serves this purpose. But unfortunately i don't have this header file.

@ robtillaar: couldn't find it over there.
Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What operating system are you using ?
Did you download ad uncompress the Arduino zip file ?
HardwareSerial is part of Arduino core libraries.
Where did you read about UART.read() ?

Also, if you're thinking about using a software serial implementation, why are you looking for a _hardware_ serial library ?
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 220
Posts: 13836
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

on my PC this is one of the arduino paths

C:\Program Files (x86)\arduino-0022\hardware\arduino\cores\arduino

and the red part is different depending on IDE version

Code:
need to collect the serial data from the UART directly to a variable, through a software serial port.
Are you familiar with the Serial class? It abstracts the hardware uarts,

if (Serial.available() > 0) x = Serial.read();
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 @robtillaart & @tuxduino: I am using ubuntu 11. I downloaded and installed arduino 0022 using the 'software centre' of ubuntu. Installation takes place automatically once the download is done.
The problem i faced was that i couldn't include the header file HardwareSerial.h in my program and hence i couldn't invoke the function UART.Read() (which i came across in a forum long time ago).
My requirement, in short, is to collect a serial data into a variable. By using "if (Serial.available() > 0) x = Serial.read()", we can collect data into variable x, only if we type the required string within the "Serial Monitor" of arduino. What i am trying is, to transmit a data, for example, "Serial.myPrint("arduino");", which will be transmitted via the 'tx' pin 3(which is set as my software 'tx' pin; pin 2 is the software 'rx') and collect the same into a variable, via the 'rx' pin of arduino. I have shorted the 'tx' pin of arduino with the software 'rx' pin 2 and 'rx' pin of arduino with the software 'tx' pin 3.
As i mentioned, if we use "x=UART.Read()", i can read and collect a data being received by the 'rx' pin of arduino.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 220
Posts: 13836
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
By using "if (Serial.available() > 0) x = Serial.read()", we can collect data into variable x, only if we type the required string within the "Serial Monitor" of arduino.
Definitely NOT true.

Serial.print() writes to the hardware tx pin, Serial.Read() reads from the hardware rx pin. 
You don't need to use UART.Read() but you can.

The serial monitor of the IDE can connect to the COM port (/dev/tty...) the Arduino has. This port is connected to the pins 0 and 1 too.
Any serial application can connect to the COM port (/dev/tty...) and read data from the Arduino. That is not restricted to the IDE.

Quote
My requirement, in short, is to collect a serial data into a variable.

x = Serial.Read() does just that.

Quote
What i am trying is, to transmit a data, for example, "Serial.myPrint("arduino");", which will be transmitted via the 'tx' pin 3(which is set as my software 'tx' pin; pin 2 is the software 'rx') and collect the same into a variable, via the 'rx' pin of arduino. I have shorted the 'tx' pin of arduino with the software 'rx' pin 2 and 'rx' pin of arduino with the software 'tx' pin 3.
The Arduino is single tasking and software serial is quite time critical so having it interrupted by the hardware serial my corrupt timing especially at higher baud rates.
What baud rate are you using?

Quote
As i mentioned, if we use "x=UART.Read()", i can read and collect a data being received by the 'rx' pin of arduino.
Does that mean you have it working now?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

UART.Read()-I have only seen it. Still i can't use it.
I am using 9600 baud rate both for software and hardware serial.

Assume this scenario. In my program i am using a keypad. There are 12 keys. Once a key is pressed, a serial data corresponding to that key is transmitted. Say, for example, if first key is pressed data "Key1" is transmitted. (using Serial.Print("Key1")smiley-wink I need this data to be collected in a variable, after its transmission,through a port pin of arduino. This is the flow: A key is pressed--> Data corresponding to that key is transmitted--> Collect this data to a variable, through a port pin of arduino.

This is what i am trying to accomplish. I am using software serial to make port pin of arduino collect serial data.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 631
Posts: 50084
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I am using software serial to make port pin of arduino collect serial data.
Then why is HardwareSerial.h/.cpp relevant? You need to post code for both the sender and the receiver, so we can see what you are doing.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The reason why i wanted to use HardwareSerial.h was to use UART.Read().
I am using the same arduino board as the sender and receiver.
Sender is the hardware 'tx' pin.
Receiver is any of the port pin of arduino.

program:

#include<NewSoftSerial.h> // for software serial pins
NewSoftSerial mySerial(2,3); // sets port pin 2 as software 'rx' and pin 3 as software 'tx'
char c;
void setup()
{
Serial.begin(9600); //sets baud rate for hardware UART
mySerial.begin(9600); //sets baud rate for oftware UART
}
void loop()
{
Serial.Print("Key1"); //data sent via hardware 'tx' pin
delay(1000);
if(mySerial.available()>0)
  {
   c=mySerial.Read(); //data read via software 'rx' pin
   delay(1000);
  }
}
 
I shorted the harware 'tx' and software 'rx' pins; also the harware 'rx' and software 'tx' pins. But this code did not work. I even tried the other way around. That is, transmit via software 'tx' and receive via harware 'rx'. But that too did not work. The code for this arrangement is here:

void loop()
{
Serial.myPrint("Key1"); //data sent via software 'tx' pin
delay(1000);
if(Serial.available()>0)
  {
   c=Serial.Read(); //data read via hardware 'rx' pin
   delay(1000);
  }
}
 
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 220
Posts: 13836
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you compile this code ???
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 220
Posts: 13836
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

One question about your code (removed your comments)

Code:
#include<NewSoftSerial.h> 
NewSoftSerial mySerial(2,3);
 
char c; 

void setup()
{
  Serial.begin(9600); 
  mySerial.begin(9600); 
}

void loop()
{
  Serial.Print("Key1"); //(1) <<<<<<<<<<<<<<
  delay(1000);
  if (mySerial.available() > 0)
  {
    c=mySerial.Read(); // (2) <<<<<<<<<<<<<<<<
    delay(1000);
  }
}
So you (1) print 4 characters over hardware serial and (2) read only one in software serial and you do nothing with it.

What do you expect to happen?



Code:
void loop()
{
Serial.[color=red]myPrint[/color]("Key1"); //does not exist!!!     mySerial.print("key1") might compile
delay(1000);
if(Serial.available()>0)
  {
   c=Serial.Read();
   delay(1000);
  }
}
for the rest same problem as before.

At least if you send 4 chars you need to read 4 chars.
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Serial.myprint() was a mistake. Actual syntax is mySerial.print().

I could compile my code.

What i expect is to receive those 4 characters "key1" through the software 'rx' pin, to a variable c, once it has been transmitted over the hardware 'tx'.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 631
Posts: 50084
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I could compile my code.
Then, post your ACTUAL code.
Logged

Pages: [1] 2   Go Up
Jump to: