LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-07-2013, 01:46 AM   #1
Sanpreet Singh
Member
 
Registered: Jan 2013
Location: Malout,Punjab
Distribution: Ubuntu(Debian), Windows
Posts: 36
Blog Entries: 1

Rep: Reputation: Disabled
End of file in C programming for readings


Code:
Hi! This is my code. Working fine

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

void loop()  
{
  int s1[2];
  int s2[2];
  s1[1] = analogRead(A1);
  s2[1] = analogRead(A2);
  Serial.println(s1[1]);
  Serial.println(s2[1]);
  delay(1000);
  s1[2] = analogRead(A1);
  s2[2] = analogRead(A2);
  if((s1[1]<s1[2])&&(s2[1]>s2[2]))
          {
                  exit(1); 
          }
  else
          {  
          Serial.println(s1[2]);
          Serial.println(s2[2]);
          delay(1000);  
          }
}
//the above is my code.

Now the problem is I want to Apply EOF in my code. The above code works fine. Definately a question come to your mind why I have to use End of file in my code. I want to run the above code using shell script in terminal in ubuntu.I have done this by using the command sudo /dev/ttyUSB0 > sensor.txt. This command puts the data of ttyUSB0 to the file called sensor.txt. But when My code end means no more reading is coming from my sensor to the arduino serial monitor or to the text file or to ttyUSB0 my script doesnot end. I think that script doesnot have end of file. This is the reason It is not ending. I am giving you the link of my github from where you can view my code of shell scipt. https://github.com/sanpreet/Automati...esting-Machine. There are five files and I have to add content to read me files. Otherfiles are ready. Even if I have tried EOF in file ttyUSB0.sh but no result. So Now I am feeling Should I insert EOF in Sensor_logic.uno. These files are contained in github. You can view them

I am trying my best to explain the problem. Help is needed.
 
Old 07-07-2013, 10:25 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,926

Rep: Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690
Quote:
Originally Posted by Sanpreet Singh View Post
Hi! This is my code. Working fine

Now the problem is I want to Apply EOF in my code. The above code works fine. Definately a question come to your mind why I have to use End of file in my code. I want to run the above code using shell script in terminal in ubuntu.I have done this by using the command sudo /dev/ttyUSB0 > sensor.txt. This command puts the data of ttyUSB0 to the file called sensor.txt. But when My code end means no more reading is coming from my sensor to the arduino serial monitor or to the text file or to ttyUSB0 my script doesnot end. I think that script doesnot have end of file. This is the reason It is not ending. I am giving you the link of my github from where you can view my code of shell scipt. https://github.com/sanpreet/Automati...esting-Machine. There are five files and I have to add content to read me files. Otherfiles are ready. Even if I have tried EOF in file ttyUSB0.sh but no result. So Now I am feeling Should I insert EOF in Sensor_logic.uno. These files are contained in github. You can view them

I am trying my best to explain the problem. Help is needed.
Not sure what you need help WITH. You've got working code, and have one problem which you have identified and have a solution for. So, implement the solution. What are you having problems with?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash programming-append single line to end of file pheasand Linux - General 4 02-28-2014 10:41 AM
[SOLVED] Add lines end of file above the end comments bkone Programming 2 02-27-2012 10:58 AM
Running a Crafted bash script yelds 'Unexpected end of file' at the end of the file MCLover1337 Linux - General 5 10-15-2011 09:29 AM
end of file function never exits : C programming exvor Programming 6 10-05-2006 12:35 PM


All times are GMT -5. The time now is 04:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration