Pages: 1 ... 4 5 [6] 7   Go Down
Author Topic: RFID Video Daemon  (Read 3973 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
2b/!2b
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does anybody have any possibilities for me please.

I have worked hard on this and got too far to turn back.

There is a solution somewhere, I'm sure of it.

Could someone please look at my code and help me.

Thank you very much.
Logged

0
Online Online
Shannon Member
****
Karma: 117
Posts: 10106
:(){:|:&};: TOX id: fcb8e918bef08581e23f6ddf9d4dba77697c25b217bf372736ed959a95fde36df5b8c5b90fbb
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

IMHO the error is here(arduino code):
Code:
if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading
            break;                       // stop reading
          }
Logged

my Arduino code: https://github.com/lestofante/arduinoSketch
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
2b/!2b
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your post.

I don't understand what the val is in relation to? The command variable?

Quote
if (length(command)!=10){ break; }

So there is not a possibility of using another file or program to close and open the daemon file that plays the video?

Thank you for replying, no other idea's out there any where?

Hope to hear something back
Logged

0
Online Online
Shannon Member
****
Karma: 117
Posts: 10106
:(){:|:&};: TOX id: fcb8e918bef08581e23f6ddf9d4dba77697c25b217bf372736ed959a95fde36df5b8c5b90fbb
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sorry, I was wrong. the error is:

if(bytesread == 10) {              // if 10 digit read is complete
        Serial.println(code);            // print the TAG code
      }

should be

if(bytesread == 10) {              // if 10 digit read is complete
        code[10]='\0'; //add end of string signal
        Serial.print(code);            // print the TAG code
      }

add the end string signal and remove the "ln" in the print, or in processing you will read \n as character. probably processing should read 11 char, because the last is \0, i dunno, just test
Logged

my Arduino code: https://github.com/lestofante/arduinoSketch
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
2b/!2b
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is so annoying if the error was at the start, but that would make sense.

Somehow I have updated the arduino with the code and tested the arduino and it works, why i left println instead of print i have no idea.

Your right, 10 variable is 0 inclusive, that would make sense.

I'm still getting a error on the processing side, a null pointer exception in the draw method at this line:

synchronized(playingMovie) {//to be sure we don't change video while it is changed by Serial command

I thought it was because it didn't have a video to play but there is sound coming from the program, it is loading file1 straight away.

Also, the sound turns off after 3 seconds.

I used your code previously submitted.

Should the if (playingMovie != null) code be above the synchronize?

Thanks so much for your help again.

Maybe it is feasible.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
2b/!2b
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

oh my, the previous code that I was working with actually works now.

The error was in the arduino board, I would never of thought of that.

That was perfect what you said and println was the problem too.

Now its just a matter of the sound playing all the way through.

I can extract the audio no problem if needed.

I will put the code I was originally using:

Quote
import processing.serial.*;
import processing.video.*;
import jmcvideo.*;

Serial myPort;  // The serial port
Movie myMovie;

void movieEvent(Movie m) {
  m.read();
}

void setup() {
    size(400,400,P3D);
  // Open whatever port is the one you're using.
  myPort = new Serial(this, Serial.list()[1], 2400);

  background(0);
 
}

void draw() {
while (myPort.available() >= 10) {
  //Video Code:
  String command = "";
  for (int i=0;i<10;i++){
     command += myPort.readChar();
  }
  println(command);
  myMovie = new Movie(this, command+".mov");
  //myMovie.setSize();
  myMovie.play();
}
 
  if (myMovie != null){
      image(myMovie, 0, 0);
       //image(myMovie, 0, 0, width, height);
  }
 
}

Thank you sooooo much, your obviously very knowledgable with arduino!!!!!  smiley-mr-green
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
2b/!2b
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Should I mark this as solved and create a new forum post asking about the audio?

I can't thank you enough lesto.
Logged

0
Online Online
Shannon Member
****
Karma: 117
Posts: 10106
:(){:|:&};: TOX id: fcb8e918bef08581e23f6ddf9d4dba77697c25b217bf372736ed959a95fde36df5b8c5b90fbb
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 smiley-cool
for the audio open a new thread, this is enough full smiley

but if you are going to play audio with processing is better use their forum, here is a little off-topic
Logged

my Arduino code: https://github.com/lestofante/arduinoSketch
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
2b/!2b
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have got audio to work now.

The only problem is the video plays as if it has lag.

I've asked for help on the processing forum.

Thought I would mention is here as well.

Thanks again.
Logged

0
Online Online
Shannon Member
****
Karma: 117
Posts: 10106
:(){:|:&};: TOX id: fcb8e918bef08581e23f6ddf9d4dba77697c25b217bf372736ed959a95fde36df5b8c5b90fbb
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

maybe this is because you read serial in draw... serial is really slow, so try to use serialEvent
Logged

my Arduino code: https://github.com/lestofante/arduinoSketch
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
2b/!2b
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Perfect smiley-mr-green

Now I need to work out how to stop the audio files from overlapping.

I was thinking of using: myMovie.dispose();  player.close(); and minim.stop(); but i'm not sure where to put it.

Updated Code:
Code:
import processing.serial.*;
import processing.video.*;
import jmcvideo.*;
import ddf.minim.*;

AudioPlayer player;
Minim minim;

Serial myPort;  // The serial port
Movie myMovie;

void movieEvent(Movie m) {
  m.read();
}

void setup() {
    size(320,240,P3D);
     minim = new Minim(this);
  // Open whatever port is the one you're using.
  myPort = new Serial(this, Serial.list()[1], 2400);

  background(0);
 
}

void draw() {

 
  if (myMovie != null){
      image(myMovie, 0, 0);
      smooth();
      ///image(myMovie, 0, 0, 320, 240);
  }
 
}

void serialEvent(Serial p){
  while (myPort.available() >= 10) {
   //Video Code:
  String command = "";
  for (int i=0;i<10;i++){
     command += myPort.readChar();
  }
  println(command);
  myMovie = new Movie(this, command+".mov");
  player = minim.loadFile(command+".wav", 2048);
  //myMovie.setSize();
  myMovie.play();
  player.play();
  }
}

Many Thanks
Logged

0
Online Online
Shannon Member
****
Karma: 117
Posts: 10106
:(){:|:&};: TOX id: fcb8e918bef08581e23f6ddf9d4dba77697c25b217bf372736ed959a95fde36df5b8c5b90fbb
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

put them before
myMovie = new Movie(this, command+".mov");
player = minim.loadFile(command+".wav", 2048);

you just have to check that myMovie isn't null
Logged

my Arduino code: https://github.com/lestofante/arduinoSketch
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
2b/!2b
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Working great now.

I had to put them after the code mentioned.

Sometimes i get a null pointer reference but the program still works.

Thank you this is great.

You've been a great help.

Thank you
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
2b/!2b
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The video's are playing and the sound is playing but every so often the file will crash and deliver this report:

Quote
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7
3600A9C9F8
360073D274
3600A9C9F8
F0000000F0
The file "F0000000F0.mov" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
error, disabling serialEvent() for //./COM4
java.lang.reflect.InvocationTargetException
   at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at processing.serial.Serial.serialEvent(Unknown Source)
   at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732)
   at gnu.io.RXTXPort.eventLoop(Native Method)
   at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1575)
Caused by: java.lang.NullPointerException
   at quicktime.util.QTHandle.<init>(QTHandle.java:287)
   at processing.video.Movie.init(Unknown Source)
   at processing.video.Movie.<init>(Unknown Source)
   at processing.video.Movie.<init>(Unknown Source)
   at dumdum.serialEvent(dumdum.java:80)
   ... 7 more
Logged

0
Online Online
Shannon Member
****
Karma: 117
Posts: 10106
:(){:|:&};: TOX id: fcb8e918bef08581e23f6ddf9d4dba77697c25b217bf372736ed959a95fde36df5b8c5b90fbb
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

some time your rfid read "F0000000F0" and there is no video with such name.
Logged

my Arduino code: https://github.com/lestofante/arduinoSketch
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Pages: 1 ... 4 5 [6] 7   Go Up
Jump to: