Can't get output of button to a byte array
I am trying to get the output values of TestButtonHandler to become byte h[] in the connect method. Of course, when I compile it, the button System.out.println works but I get a null pointer exception at
byte h[] = asciiStream.toByteArray(); Would someone give me a clue as to why there's a disconnect? thx
public class MonitorView2 extends JFrame {
static SerialPort serialPort;
ByteArrayOutputStream asciiStream;
public MonitorView2() {
super("Monitor View 2");
JPanel pane = new JPanel();
setContentPane(pane);
JButton testButton = new JButton("Test Comm On");
pane.add(testButton);
setSize(600, 300);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
class TestButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
System.out.println("Test button action works!");
try
byte h[] = {33, 48, 48, 66, 67, 78, 49, 13}; //comm on;
ByteArrayOutputStream asciiStream = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(asciiStream);
oos.writeObject(h);
oos.close();
catch (Exception ex)
System.out.println("Exception has been thrown :" + ex);
testButton.addActionListener( new TestButtonHandler());
public void connect ( String portName ) throws Exception {
String defaultPort = "/dev/ttyS0";
String asciiString;
Charset asciiCharset = Charset.forName("US-ASCII");
CharsetDecoder decoder = asciiCharset.newDecoder();
byte h[] = asciiStream.toByteArray();
//byte h[] = {33, 48, 48, 66, 67, 78, 49, 13}; //comm on
ByteBuffer asciiBytes = ByteBuffer.wrap(h);
CharBuffer hChars = null;
try {
hChars = decoder.decode(asciiBytes);
} catch (CharacterCodingException e) {
System.err.println("Error decoding");
System.exit(-1);
System.out.println(hChars);
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
if ( portIdentifier.isCurrentlyOwned() )
System.out.println("Error: Port is currently in use");
else
CommPort commPort = portIdentifier.open(this.getClass().getName(),2000);
if ( commPort instanceof SerialPort )
SerialPort serialPort = (SerialPort) commPort;
serialPort.setSerialPortParams(4800,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
InputStream in = serialPort.getInputStream();
OutputStream out = serialPort.getOutputStream();
(new Thread(new SerialReader(in))).start();
(new Thread(new SerialWriter(out))).start();
out.write(h);
out.flush();
else
System.out.println("Error: Only serial ports are handled by this example.");
ByteArrayOutputStream asciiStream = new ByteArrayOutputStream();By actually using the attreibute instead of declaring and initializing another local variable with the same name:
asciiStream = new ByteArrayOutputStream();
Similar Messages
-
How can you get your submit buttons on the quiz template to be a single click instead of the default double click? (The option to choose double click or not is not showing in properties for this).
Hmmm... Submit button doesn't need a double click at all. Maybe you are talking about the two-step process? When you click on Submit, the feedback appears with the message to click anywhere or press Y. Is that what you are talking about? If you are talking about a real double-click, something must be wrong in your file. And which version are you using?
http://blog.lilybiri.com/question-question-slides-in-captivate
Lilybiri -
I have Windows 7 and PS Elements 10 and can't get the text button to work properly. What can I do?
Try selecting the T tool and then doing a reset (see image below)
-
Answer: to How can I get the reset button to work.
How can I get the reset button to work?: Answer
Thanks to everyone who helped on this. You are awesome. Especially Ned!! Posted here because I was unable to add more to the existing post.
Here is the question:
When you click on the reset button, this error below comes up. If you can't find the button it is the navy colored rectangular thing in the lower left corner of page.
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at AddATree2/onReset()
When you click on the reset button, this error below comes up. If you can't find the button it is the navy colored rectangular thing in the lower left corner of page.
Here is the answer:
//when you click the reset button everything is removed from the stage
//except the star, baclground, and reset button (trees and greeting REMOVED)
public function onClear(Event:MouseEvent):void
if (tree3) removeChild(tree3);
if (tree2) removeChild(tree2);
if (webText) removeChild(webText);
if (tree) removeChild(tree);
clickCount = 0;This is the answer to what to put in the onclear function.
-
Urgent!! PL/SQL web service can not get output param in BPEL
OC4J 10.1.2 generate PL/SQL web service can not get output param can not get output param in BPEL when call a pl/sql webservice.
wsdl as follow:
<types>
<schema targetNamespace="http://db.func.getqf/COMMON.xsd" xmlns:tns="http://db.func.getqf/COMMON.xsd" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<complexType name="db_func_getqf_COMMONUser_getqf_Out">
<all>
<element name="pnqfysOut" type="xsd:decimal"/>
<element name="pnzqfOut" type="xsd:decimal"/>
</all>
</complexType>
</schema>
</types>
<message name="getqfOutput">
<part name="return" type="xsd1:db_func_getqf_COMMONUser_getqf_Out"/>
</message>the wsdl which generate by OC4J is as follows:
<?xml version="1.0" ?>
- <definitions name="COMMON" targetNamespace="http://db.func.getqf/COMMON.wsdl" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://db.func.getqf/COMMON.wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd1="http://db.func.getqf/COMMON.xsd">
<documentation>WSDL for Service: COMMON, generated by Oracle WSDL toolkit (version: 1.1)</documentation>
- <types>
- <schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://db.func.getqf/COMMON.xsd" xmlns:tns="http://db.func.getqf/COMMON.xsd" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <complexType name="db_func_getqf_COMMONUser_getqf_Out">
- <all>
<element name="pnqfysOut" type="xsd:decimal" />
<element name="pnzqfOut" type="xsd:decimal" />
</all>
</complexType>
</schema>
</types>
- <message name="getqfOutput">
<part name="return" type="xsd1:db_func_getqf_COMMONUser_getqf_Out" />
</message>
- <message name="getqfInput">
<part name="param0" type="xsd:string" />
</message>
- <portType name="COMMONPortType">
- <operation name="getqf">
<input message="tns:getqfInput" />
<output message="tns:getqfOutput" />
</operation>
</portType>
- <binding name="COMMONBinding" type="tns:COMMONPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
- <operation name="getqf">
<soap:operation soapAction="urn:db-func-getqf-COMMON/getqf" />
- <input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:db-func-getqf-COMMON" />
</input>
- <output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:db-func-getqf-COMMON" />
</output>
</operation>
</binding>
- <service name="COMMON">
- <port name="COMMONPort" binding="tns:COMMONBinding">
<soap:address location="http://localhost:9700/plsqlgetqf/getqf" />
</port>
</service>
</definitions> -
In Yosemite, How can I get the "READER" button back in the Tool Bar at the top of the screen
In OS X Yosemite,
How can I get the "READER" button back in the Tool Bar for Safari at the top of the screen ?
Thanks,I don't see the "READER button".
I see "READ LATER" but not the "READER" function.
Maybe I'm doing it wrong.
Please continue to HELP ME with this question.
In the previous version of Safari, there was a "READER Button" on the right side of the tool bar. This brings up the selected web page in a READER mode all by itself, without the ads, etc.
Are you saying that I can get this function by clicking on the Left side of the Address bar?
When I do that, I get lots of icons, but NOT the READER button.
Thanks -
TS3274 I can not get my video button to work
I can not get my video button to work, it will not response when I try to use it
Try sliding the words up or down to select the various modes.
-
How can I get my home button to work again
How can I get my home button to work again
Well, if your Home button is broken, you won't be able to reset your phone, and if the Sleep/Wake button won't turn your phone on, it's a trip to the Apple store.
-
Can't get past continue button
Just got a request to run and update. Update completed. Upon restart, What's new splash screen. Continue button has blue ring around it (selected) but I only have iPad remote control or iPhone remote control and gestures (tap, double tap) not working. Can't get past the What's new button.
Tried a restart hoping to get past, but no luck.
Don't tell me I have to go re-purchase an apple remote.Could you send us a link to your form so we can take a look at it. Send it to [email protected]
Thanks,
Randy -
How can I get my radio buttons on one line?
I have tried to put two radio buttons in one text cell in a table, but I can´t get them side by side. They stack on top on each other, in a vertical list, no matter what I do.
Sorry for the stupid qustion, but this is my first attempt in LiveCycle Designer.Thanks for your time. I found the soloution. I changed the flow direction in the suborm from "top to bottom" to "Western text"
-
I am trying to convert a .jpg to an eps using trace (never done it before) and I thought I had gone through all the preliminaries correctly. [Using AI CC] When I either open the file directily or place it in a new file when I open the trace window there is nothing I can do the will get the "trace" button to light. The videos (both Linda and Adobe) seem to have it lit just begging to be touched but is just looking at me implying that I have forgotten something important and I haven't a clue. Thoughts?
Did you place the image or paste it?
Pasting will create a clipping mask, which won't work. Placing works. Select the image and just select a preset. -
I can't get the Web Gallery button on my iPhone. I do have iLife '08, .Mac account and published successfully albums to Web Gallery on .Mac from iPhoto. I followed the instructions how to transfer the albums to iPhone. I factory restored my iPhone and I restarted my iPhone. I'm up to date with my software. I use .Mac email account as default. I followed the discussions on this issue, which only some of you have, in iPhone forum. I still can't get the button on my iPhone and open the Web Gallery there.
MilanMy Apple Mail account is .Mac. I can delete this account on iPhone and sync it back on iTunes without difficulties. The account works both on iPhone and my desktop. Web Gallery button doesn't show up no matter what I do. As a test I published new set of pistures to my Gallery. The album is on .Mac but I can't see it on iPhone because I don't have the button.
My approach to any issues is that I first blame myself and then Apple. I don't know what else I could do wrong to cause this problem. Still I believe it's a small hitch somewhere.
I appreciate your concern and help.
Milan -
I can't get the edit button in iPhoto to open the edit feature
I can't get the edit function in I photo to work
First try the following:
1 - delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your
User/Home/Library/ Preferences folder.
2 - delete the contents the following folder:
User/Library/Containers/com.apple.iPhoto
3 - reboot, launch iPhoto and try again.
NOTE: For Mavericks and Yosemite, go to your Home folder and use the View ➙ Show View Options menu to bring the this window:
where you can check the Show Library Folder checkbox. -
Can't get extra mouse buttons to do anything
When I first used my macbook air with my logitech usb mouse, the computer asked me what the uses of the two buttons on the side were. I can't remember what I did, but whatever it was it must have been wrong. I assumed I would be able to change that later if I actually needed them. Now, I need the use of the buttons, but whenever I open a program to bind keys, pressing either of the buttons results in the same input as if I'd pressed the middle click - rendering them both useless. I trawled through system preferences but can't find where to separate the buttons or even if that's what I need to do. Help?
System preferences, Mouse for the main settings. As far as the other buttons, there is usually a configuration program provided by the mouse manufacturer.
If you go to mission control, you can also select extra mouse buttons to open spaces, expose, etc.
Message was edited by: ssschmidt -
How can I get one Submit button to perform three actions?
I have a 2-page form. One page is completed by an HR person, entering fields that describe a new role, new pay, new hours or a new location for an existing employee. The second page automatically repeats the name, location and job role fields, but also completes the IT requirements linked to the job role (such as whether or not the role needs access to a particular piece of software or not).
The users of the form will have varying degress of IT capability. I wan to enable them to press a single Submit button that does three things: first, print the first page of a two-page form AND e-mail the same page to one e-mail address. Second: e-mail the second page only to a DIFFERENT e-mail address.
I am not a Javascript expert - or even a beginner. Can anyone help? I need to get this ready for Tuesday! Thanks in advanceYou will need two buttons on your form to be able to do this.
One is the actual submit button (this will interact with th email system and do the submit). Note that you cannot write programs on a submit button. You will need to make this button invisible to the user. The second button will be a regular button which you can write programs on. Use teh click event of that button. This one will have logic to accomplish the things that you want ...here is some pseudo code to do this:
use print command and one of the parms indicates which pages to print.
Set up the submit button to hold the email address of the person recieving it.
Programmatically click the hidden submit button.
Note that the user will recieve a dialog from the mail client to OK before teh form will be sent.
Set up the submit button to change the email address
Programmatically click the submit button again
User will recieve another dialog to OK the email submission
Also you cannot email part of the form it will have to be the whole form. You coudl get a little more sophisticated and hide parts of the form but the whole form will be sent with the emails. This will need more programming on your part.
Paul
Maybe you are looking for
-
Question: I have a mac and an ipad. when i create an ical event on my mac and then sync, the event transfers to my ipad. HOWEVER: when i create an ical event on my ipad and then sync, the event does not transfer. what am i doing wrong??? cadybill
-
Mac mini won't boot after 10.6.8 Update
I've recently installed the latest update and now I'm stuck on the grey logo with the spinning wheel. I've reset the pram etc and when sarting in verbose mode it seems to be stalling at the following stage. CSRUSBBluetoothHCIController::setupHardware
-
Soft proofing: how to A/B?
Hi all, I'm kinda new to soft proofing, so maybe this is a silly question, but here goes: My workflow for printing is that i first tweak my photos so they look like how i want them on my computer monitor, for uploading to Flickr. After that i choose
-
Can I buy a headset with microphone for my 13" MACBOOK PRO?
There is only one hole to plug an earphone, and when i record in my software, and i replay it. it sounds strange. so i'm trying to change a microphone. is the headset with microphone for A1278 on sale? could somebody give me an sale net address?
-
System unusable when RAM is full
There was always this thing that annoyed me: When the RAM is full and the swapping starts the System is getting slow as hell. And by system I mean the GUI: X + DE. I sometimes had the problem that there was an application that ate all the RAM and the