We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
write to serial port (Read 1527 times)
write to serial port
Sep 24th, 2007, 3:02am
 
I am trying to send out data from processing into a pic bs2 micro-controller if i run the following program one out four times I get this error.

Stable Library

=========================================

Native lib Version = RXTX-2.1-7

Java lib Version   = RXTX-2.1-7

[0] "COM3"

[1] "COM4"


java.lang.NullPointerException

at processing.serial.Serial.serialEvent(Serial.java:221)

at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732)


I doesn't happen every time and never after I restart my computer. What is causing this I am new to this type of programming so please excuse me if it is an obvious problem.

this is my processing code

<CODE>
import processing.serial.*;

// The serial port:
Serial myPort;

// List all the available serial ports:
println(Serial.list());


myPort = new Serial(this, Serial.list()[1], 2400);

myPort.clear();

// Send a capital A out the serial port
myPort.write(65);
</CODE>

this is the code i have on the bs2

<CODE>
' {$STAMP BS2}
' {$PBASIC 2.5}


proIn VAR Byte

Main:
 DO

   proIn = IN10

   SERIN 16, 16780, [proIn]
   IF proIn = 65 THEN
     HIGH 14
   ENDIF
   PAUSE(250)

 LOOP
 END
</CODE>
Re: write to serial port
Reply #1 - Sep 24th, 2007, 4:43pm
 

...are you on an OS X machine? If so, be sure to run macosx_setup.command and/or fix your permissions. I had the same errors that would always be fixed by restarting. That was over a year ago though..
Re: write to serial port
Reply #2 - Sep 24th, 2007, 7:40pm
 
I am using widows XP
Re: write to serial port
Reply #3 - Sep 26th, 2007, 5:32pm
 
I got it i needed to make sure the port was available first.

<code>


import processing.serial.*;

// The serial port:
Serial myPort;

// List all the available serial ports:
println(Serial.list());

myPort = new Serial(this, Serial.list()[1], 2400);

println(myPort.available());

 while (myPort.available() == 0) {
   delay(300);
   myPort.write(65);

 }
 
</code>
Page Index Toggle Pages: 1