justinh Posted February 2, 2009 Share Posted February 2, 2009 <?php if ( isset ( $_GET['clearbanker'] ) ){ $objComport = new COM ( "ActiveXperts.Comport" ); $objComport->Logfile = "C:\\PhpSerialLog.txt"; $objComport->Device = "COM5"; $objComport->Baudrate = 57600; $objComport->ComTimeout = 1000; $objComport->Open (); if ( $objComport->LastError == 0 ) { Echo "Clearing Banker..<BR>"; Echo "<BR>"; $objComport->WriteString ( "C" ); while ( $objComport->LastError == 0 ) { Echo "<b>".$objComport->ReadString () . "</b>"; Echo "<BR>"; } } else { $ErrorNum = $objComport->LastError; $ErrorDes = $objComport->GetErrorDescription ( $ErrorNum ); Echo "Error sending commands: #$ErrorNum ($ErrorDes)."; } Echo "Ready."; $objComport->Close (); } if ( isset ( $_GET['mode'] ) ){ switch($_GET['mode']){ case "Dollars": $objComport = new COM ( "ActiveXperts.Comport" ); $objComport->Logfile = "C:\\PhpSerialLog.txt"; $objComport->Device = "COM5"; $objComport->Baudrate = 57600; $objComport->ComTimeout = 1000; $objComport->Open (); if ( $objComport->LastError == 0 ) { Echo "Scoop Mode..<BR>"; Echo "<BR>"; $objComport->WriteString ( "S 1-" ); while ( $objComport->LastError == 0 ) { Echo "<b>".$objComport->ReadString () . "</b>"; Echo "<BR>"; } } else { $ErrorNum = $objComport->LastError; $ErrorDes = $objComport->GetErrorDescription ( $ErrorNum ); Echo "Error sending commands: #$ErrorNum ($ErrorDes)."; } Echo "Ready."; $objComport->Close (); break; case "Pennies": $objComport = new COM ( "ActiveXperts.Comport" ); $objComport->Logfile = "C:\\PhpSerialLog.txt"; $objComport->Device = "COM5"; $objComport->Baudrate = 57600; $objComport->ComTimeout = 1000; $objComport->Open (); if ( $objComport->LastError == 0 ) { Echo "Scoop Mode..<BR>"; Echo "<BR>"; $objComport->WriteString ( "S 1c" ); while ( $objComport->LastError == 0 ) { Echo "<b>".$objComport->ReadString () . "</b>"; Echo "<BR>"; } } else { $ErrorNum = $objComport->LastError; $ErrorDes = $objComport->GetErrorDescription ( $ErrorNum ); Echo "Error sending commands: #$ErrorNum ($ErrorDes)."; } Echo "Ready."; $objComport->Close (); } break; } ?> The code works fine, just giving an error of Fatal error: Cannot break/continue 1 level in C:\xampp\htdocs\counting\clear.php on line 135. It works, but was just wondering why this error is displaying. Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted February 2, 2009 Share Posted February 2, 2009 put the break; before the last bracket Quote Link to comment Share on other sites More sharing options...
justinh Posted February 2, 2009 Author Share Posted February 2, 2009 duh, thanks Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted February 2, 2009 Share Posted February 2, 2009 awesome.. glad to help... make sure to click the topic solved button Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.