need help in programming method declaration problem
Currently I am testing CMUCam3 vision sensor in Javelin stamp, I tried to test a program like below.However, the Java IDE got indicate : [noparse][[/noparse]Java Error] CMU_M.java(32): Error: The method "FullRest" does not denote a class method.
Any one can help me about this, thank you very much.
Btw, any one got use CMUcam3 vision sensor in javelin before or can provide any sample program?
import stamp.core.*;
import stamp.util.text.*;
class CMU3_M{
final static int TX = CPU.pin0;
final static int RX = CPU.pin2;
static Uart m_uartTx = new Uart( Uart.dirTransmit, TX, Uart.dontInvert, Uart.speed38400,Uart.stop1 );
static Uart m_uartRx = new Uart( Uart.dirReceive, RX, Uart.dontInvert, Uart.speed38400,Uart.stop1 );
Timer m_timer = new Timer();
static StringBuffer m_buffTemp = new StringBuffer(32);
static char[noparse]/noparse m_rgchBuff = new char[noparse][[/noparse]8];
static boolean m_fInit = false;
static boolean m_fRGB = true;
static boolean m_fAutoWhite = false;
static int m_nFrameSpeed = 2;
static int m_nX1 = 1;
static int m_nY1 = 1;
static int m_nX2 = 80;
static int m_nY2 = 143;
static int m_nTrackingMode = 0;
public static void main()
{
for(int i=0;i<2;i++)
{
FullReset();
CPU.delay(100);
System.out.println("reset completed!!");
}
}
public boolean FullReset()
{
// Send CR to make sure that camera is in idle mode
m_uartTx.sendString("\r");
if ( !WaitForPrompt() )
{
return false;
}
// Reset the camera
m_uartTx.sendString("RS\r");
if ( !WaitForPrompt() )
{
return false;
}
// Configure camera for raw mode
m_uartTx.sendString("RM 1\r");
if ( !WaitForACKPrompt() )
{
return false;
}
m_fInit = true;
return true;
}
protected boolean WaitForPrompt()
{
char ch = 0;
// Retrieve last character sent back from camera
m_timer.mark();
while ( !m_timer.timeout(100) )
{
// If there is a byte available, get it and store it
if ( m_uartRx.byteAvailable() )
{
ch = (char) (0xff & m_uartRx.receiveByte());
m_timer.mark();
}
}
// Was the ":" prompt encountered
if ( ch == ':' )
{
return true;
}
else
{
return false;
}
}
protected boolean WaitForACKPrompt()
{
ClearBuffer();
// Retrieve last 5 characters sent back from camera
m_timer.mark();
while ( !m_timer.timeout(100) )
{
// If there is a byte available, get it and store it along
// with the last 4 bytes retrieved.
if (m_uartRx.byteAvailable() )
{
m_rgchBuff[noparse][[/noparse]0] = m_rgchBuff;
m_rgchBuff = m_rgchBuff;
m_rgchBuff = m_rgchBuff;
m_rgchBuff = m_rgchBuff;
m_rgchBuff = (char) (0xff & m_uartRx.receiveByte());
m_timer.mark();
}
}
// Were the last 5 characters "ACK\r:"
if ( m_rgchBuff[noparse][[/noparse]0] == 'A' &&
m_rgchBuff == 'C' &&
m_rgchBuff == 'K' &&
m_rgchBuff == '\r'&&
m_rgchBuff == ':' )
{
System.out.println(m_rgchBuff[noparse][[/noparse]0]);
System.out.println(m_rgchBuff);
System.out.println(m_rgchBuff);
System.out.println(m_rgchBuff);
System.out.println(m_rgchBuff);
return true;
}
else
{
return false;
}
}
protected void ClearBuffer()
{
int i = 0;
for ( i = 0 ; i < m_rgchBuff.length ; i++ )
{
m_rgchBuff = 0;
}
}
}
Any one can help me about this, thank you very much.
Btw, any one got use CMUcam3 vision sensor in javelin before or can provide any sample program?
import stamp.core.*;
import stamp.util.text.*;
class CMU3_M{
final static int TX = CPU.pin0;
final static int RX = CPU.pin2;
static Uart m_uartTx = new Uart( Uart.dirTransmit, TX, Uart.dontInvert, Uart.speed38400,Uart.stop1 );
static Uart m_uartRx = new Uart( Uart.dirReceive, RX, Uart.dontInvert, Uart.speed38400,Uart.stop1 );
Timer m_timer = new Timer();
static StringBuffer m_buffTemp = new StringBuffer(32);
static char[noparse]/noparse m_rgchBuff = new char[noparse][[/noparse]8];
static boolean m_fInit = false;
static boolean m_fRGB = true;
static boolean m_fAutoWhite = false;
static int m_nFrameSpeed = 2;
static int m_nX1 = 1;
static int m_nY1 = 1;
static int m_nX2 = 80;
static int m_nY2 = 143;
static int m_nTrackingMode = 0;
public static void main()
{
for(int i=0;i<2;i++)
{
FullReset();
CPU.delay(100);
System.out.println("reset completed!!");
}
}
public boolean FullReset()
{
// Send CR to make sure that camera is in idle mode
m_uartTx.sendString("\r");
if ( !WaitForPrompt() )
{
return false;
}
// Reset the camera
m_uartTx.sendString("RS\r");
if ( !WaitForPrompt() )
{
return false;
}
// Configure camera for raw mode
m_uartTx.sendString("RM 1\r");
if ( !WaitForACKPrompt() )
{
return false;
}
m_fInit = true;
return true;
}
protected boolean WaitForPrompt()
{
char ch = 0;
// Retrieve last character sent back from camera
m_timer.mark();
while ( !m_timer.timeout(100) )
{
// If there is a byte available, get it and store it
if ( m_uartRx.byteAvailable() )
{
ch = (char) (0xff & m_uartRx.receiveByte());
m_timer.mark();
}
}
// Was the ":" prompt encountered
if ( ch == ':' )
{
return true;
}
else
{
return false;
}
}
protected boolean WaitForACKPrompt()
{
ClearBuffer();
// Retrieve last 5 characters sent back from camera
m_timer.mark();
while ( !m_timer.timeout(100) )
{
// If there is a byte available, get it and store it along
// with the last 4 bytes retrieved.
if (m_uartRx.byteAvailable() )
{
m_rgchBuff[noparse][[/noparse]0] = m_rgchBuff;
m_rgchBuff = m_rgchBuff;
m_rgchBuff = m_rgchBuff;
m_rgchBuff = m_rgchBuff;
m_rgchBuff = (char) (0xff & m_uartRx.receiveByte());
m_timer.mark();
}
}
// Were the last 5 characters "ACK\r:"
if ( m_rgchBuff[noparse][[/noparse]0] == 'A' &&
m_rgchBuff == 'C' &&
m_rgchBuff == 'K' &&
m_rgchBuff == '\r'&&
m_rgchBuff == ':' )
{
System.out.println(m_rgchBuff[noparse][[/noparse]0]);
System.out.println(m_rgchBuff);
System.out.println(m_rgchBuff);
System.out.println(m_rgchBuff);
System.out.println(m_rgchBuff);
return true;
}
else
{
return false;
}
}
protected void ClearBuffer()
{
int i = 0;
for ( i = 0 ; i < m_rgchBuff.length ; i++ )
{
m_rgchBuff = 0;
}
}
}
Comments
I have not seen any CMU3 code.
regards peter
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The truth in physics is changed with time.