Comm serial API CR LF Problem

Hello People,
I am trying to send :
<ID01>toms messsage [cr] [lf]
to the serail port using the comm API. (To an LED display unit)
How do I send the ASCI codes for [cr] [lf]???
I tryed this : (changes the SimpleWrite.java, that comes with the comm API are marked)
import java.io.*;
import java.util.*;
import javax.comm.*;
public class SimpleWrite {
static Enumeration portList;
static CommPortIdentifier portId;
static String messageString = ("<ID01><PA>TOM HELLO");
static SerialPort serialPort;
static OutputStream outputStream;
static char myEnterChar = '\n';<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
public static void main(String[] args) {
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
// if (portId.getName().equals("COM1")) {
if (portId.getName().equals("/dev/term/a")) {
try {
serialPort = (SerialPort)
portId.open("SimpleWriteApp", 2000);
} catch (PortInUseException e) {}
try {
outputStream = serialPort.getOutputStream();
} catch (IOException e) {}
try {
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {}
try {
outputStream.write(messageString.getBytes() );
outputStream.write(myEnterChar);
outputStream.write(myEnterChar);<<<<<<<<<
} catch (IOException e) {}

RobertWhite1, you are a hero! It works fine, here is the code for other ppl in the furture :-)
(This is using SDK 1.4.1 by the way, on Com1, to an LED sign, Windows XP)
import java.io.*;
import java.util.*;
import javax.comm.*;
public class SimpleWrite {
static Enumeration portList;
static CommPortIdentifier portId;
static String messageString = ("<ID01><PA>:-) :-) :-) :-) :-) :-) :-) :-) "+ (char)13 + (char)10+ (char)13 + (char)10);
static SerialPort serialPort;
static OutputStream outputStream;
static char myEnterChar = '\n';
static char CarrR = (char)13;
static char LineF = (char)10;
public static void main(String[] args) {
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals("COM1")) {
//if (portId.getName().equals("/dev/term/a")) {
try {
serialPort = (SerialPort)
portId.open("SimpleWriteApp", 2000);
} catch (PortInUseException e) {System.out.println(e);}
try {
outputStream = serialPort.getOutputStream();
} catch (IOException e) {System.out.println(e);}
try {
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {System.out.println(e);}
try {
outputStream.write(messageString.getBytes() );
//outputStream.write(myEnterChar);
//outputStream.write(myEnterChar);
outputStream.write(CarrR+LineF+CarrR+LineF);
} catch (IOException e) {System.out.println(e);}

Similar Messages

  • I wanted to know explain my problem down package cc2014 where I put the serial number of the problem that I have is that when you open the program asks me start of session in which he put it and go but back inside and it drives me to request the start of

    I wanted to know explain my problem down package cc2014 where I put the serial number of the problem that I have is that when you open the program asks me start of session in which he put it and go but back inside and it drives me to request the start of session and I take 3 weeks or more with this problem if they can support me solve it was the number of seire wearing this being installed at a private university

    Cloud programs do not use serial numbers... you log in to your paid Cloud account to download & install & activate... you MAY need to log out of the Cloud and restart your computer and log back in to the Cloud for things to work
    Some general information for a Cloud subscription
    Log out of your Cloud account... Restart your computer... Log in to your paid Cloud account
    -Sign in help http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html
    -http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html
    -http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html
    -http://helpx.adobe.com/creative-suite/kb/trial--1-launch.html
    Does your Cloud subscription properly show on your account page?
    If you have more than one email, are you sure you are using the correct Adobe ID?
    https://www.adobe.com/account.html for subscriptions on your Adobe page

  • HT1695 My iPad (4th gen) Wi-Fi Serial Number: DM*******184; Problem: can not connect Wi-Fi, just keep connecting...

    Dear All,
    My iPad (4th gen) Wi-Fi Serial Number: DM*******184; Problem: can not connect Wi-Fi, just keep connecting...
    Appreciate your advice.
    Thanks and regards,
    Linh Hua
    (Vietnam)
    <Edited By Host>

    Is this happening with one particular network or with all?  Make sure iOS is updated on the device.
    Try this:
    Reboot ipad by pressing and holding both the home and sleep/wake buttons at the same time until the apple logo appears on the screen, then let go. Then try to connect to network.
    Go to settings, Toggle airplane mode on/off. Make sure bluetooth is off. Turn on wif (airplane mode off). Try to connect.
    Reset Network Settings
    Go to settings/general/reset/reset network settings. Then try to connect to network.
    If its your home router, then reboot router by unplugging for 5-10min. (do this while you're resetting network settings).
    If problem persists, then check for firmware updates on your router.(you check router manufacturer support website for downloads and instructions).

  • Bash script talking to/from comm serial port

    I would like to develop a shell script that would do launchd-scheduled transfer of some ascii text and binary data to/from a serial comm port (using Keyspan SX-Pro PCI card) to an ancillary device. Can anyone suggest where I could find information on properly doing this (commands to read/write text, wait for occurrences of unique character strings from the ancillary device, initiate upload/download of binary file transfers, configure serial port parameters, and so on)?
    On an unrelated note, suppose a person wants to develop yet another shell script that would telnet into a DSL modem via RJ-45 connection and reboot it or take it offline or put it back online. I don't want to enable remote administration but I do have a phone application that can launch shell scripts upon receipt of a user-defined sequence of DTMF digits -- so the plan would be to dial in, send the DTMF code, and the shell script would locally telnet to the modem and, say, bring it back online by executing the proper linux command file that is resident in the DSL modem's firmware. Can anyone suggest where I could find information on how one should tell the shell script to wait for the occurrence of a particular character string and then send another particular character string, how to configure any pertinent communications parameters, and so forth?
    Thanx

    Been a long time since I did anything like this, but I suspect expect could help you with this. Try
    man expect
    But i think you would probably need to search for tutorials/examples since there are so many possibilities.

  • Applet/Servlet/serialized objects/HTTPS/Intranet problem

    We've got a Webapplication with[b] applets on the client and servlets on the server side.The Applet send serialized Objects over HTTPS (SSL) to the servlet. The servlet does some business logic and send the answer the same way back.
    In all our tests and in the most cases the application works without any problems.
    But in some Intranet environments we get occasionally (not definitely reproducable) the following error:
    <Oct 1, 2004 8:26:00 AM>  [AnmeldenService] {Service-readThreadAks-AnmeldenServiceThread}
    java.io.EOFException: Expecting code
    at java.io.ObjectInputStream.peekCode(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    at com.dsh.egb.aks.betrieb.rclt.service.ServiceThread$2.run(ServiceThread.java:222)
    at java.lang.Thread.run(Unknown Source)Has anybody an idea how to further analyse this problem?
    Thanks,
    Mark
    We use JRE/JDK 1.3.1_10.

    Here some more Information about our environment:
    Server: Apache 1.3.26 / Openssl 0.9.6d /WinNT 4.0 /HTTP Redirect to Tomcat 4.0.1/ JDK1.3.1_10/ WinNT 4.0
    Client: Plugin 1.3.1_10/Internet Explorer 6.0 (SSL)/Win NT 4.0

  • Solved!== Wince 6.0---Serial Driver or Kernel Problem?

    Samsung SMDKV210 Dev Board with a LCD and 4 serial ports (COM1 to COM4). A computer sends data (in packet one by one) regularly to the board through COM1. When the interval time of the packets is over 120ms, the application run on the Dev board receives
    each packet on time (T + 120xN). If the interval time is less than 110ms, such as 60ms, the app receives the data in 360ms intervally, 6 packets once a time (T + 360xN). I checked the source code but found nothing. Is there anything wrong in the CE
    kernel? Could anyone help me? Thanks.
    2014.12.21

    BOOL CPSerialPort::OpenPort(LPCTSTR Port,int BaudRate,int DataBits,int StopBits,int Parity,LPDataArriveProc proc,DWORD userdata)
        m_lpDataArriveProc=proc;
        m_dwUserData=userdata;
        if(m_hComm==INVALID_HANDLE_VALUE)
            m_hComm=CreateFile(Port,GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,0,0);
            if(m_hComm==INVALID_HANDLE_VALUE )
                AfxMessageBox(_T("Cannot open Port"));
                return FALSE;
            GetCommState(m_hComm,&dcb);
            dcb.BaudRate=BaudRate;
            dcb.ByteSize=DataBits;
            dcb.Parity=Parity;
            dcb.StopBits=StopBits;
            dcb.fParity=FALSE;
            dcb.fBinary=TRUE;
            dcb.fDtrControl=0;
            dcb.fRtsControl=0;
            dcb.fOutX=dcb.fInX=dcb.fTXContinueOnXoff=0;
            SetCommMask(m_hComm,EV_RXCHAR);        
            SetupComm(m_hComm,16384,16384);        
            if(!SetCommState(m_hComm,&dcb))
                AfxMessageBox(_T("Cannot setup Comm"));
                PurgeComm(m_hComm,PURGE_TXCLEAR|PURGE_RXCLEAR);
                ClosePort();
                return FALSE;
            GetCommTimeouts(m_hComm,&CommTimeOuts);        
            CommTimeOuts.ReadIntervalTimeout=100;
            CommTimeOuts.ReadTotalTimeoutMultiplier=1;
            CommTimeOuts.ReadTotalTimeoutConstant=100;
            CommTimeOuts.WriteTotalTimeoutMultiplier=0;
            CommTimeOuts.WriteTotalTimeoutConstant=0;    
            if(!SetCommTimeouts(m_hComm,&CommTimeOuts))
                AfxMessageBox(_T("Cannot setup Timerouts"));
                PurgeComm(m_hComm,PURGE_TXCLEAR|PURGE_RXCLEAR);
                ClosePort();
                return FALSE;
            PurgeComm(m_hComm,PURGE_TXCLEAR|PURGE_RXCLEAR);        
            return TRUE;        
        return FALSE;
    Dear Bruce,
    I hope you "hit the target". Those parameters underlined above will be adjusted in tomorrow morning's test, and I will inform you the result asap.
    BEST RGDS
    JWenbin 
                                    

  • Serial number registration ipad problem

    Hello,
    I have a question about the serial number registration,iff i wanted to register my serail number of my ipad the apple support says that the serial number all rwady is register with a other account i try every email witch i have but no hit.
    How i can fix this problem? And i am the first owner of this ipad,
    Gr.
    Faikol

    Hi Ravi
    Thank you for taking the time to reply and comment.
    I installed from the eLearning Suite 1.0 which I purchased
    online and downloaded. I had originally used a trial version of
    Captivate 4, but I removed this before I started and also used the
    CS3 Script clean up that the tech support chap talked me through.
    I can successfully open Dreamweaver, Flash, Photoshop and
    Acrobat with the serial number being used just once when asked for
    it during installation.
    However when I went to open Captivate it comes up with the
    box asking if I want to use the trial version OR put in my serial
    number. It won't accept the serial number, even though it worked
    for DW etc that came with the same Suite and was part of the same
    installation process.
    I have uninstalled once and repeated the process after the
    clean up script but get the same error and I also removed CS3 Web
    Edition before I started.
    Incidently it does work in trial mode but the days are
    counting down and I have a big project to work on over the next 6-8
    months or so.
    Kind regards, Sheila

  • JExcel api jxl.jar problem

    hi,
    I just downloaded the Jexcel API from source forge. i added the jxl.jar file to my classpath and wrote a small program. But i am getting the following error.
    Read_Excel.java:4: package jxl does not exist
    import jxl.*;
    ^I am running my program through command promt only. and i have added the jar also to folder C:\Program Files\Java\jre1.6.0_04\lib\ext
    But still same problem.
    Please help.

    Opening a new command shell and working from there, would have worked, too, but hey, if you wanted to take the time to reboot, more power to you.

  • Delphi  7 - UI API Event pVal problem

    Dear community,
    I've setup the UI API in Delphi 7 by using the generated SAPbouiCOM_TLB, most seem to work but I have a blocking problem with the eventhandling of the UI API. The pVal parameters are not passed correctly back by the event and, when accesed, cause access violations.
    There are some other threads about this problem.
    There are two answers given:
    1: Use another program then Delphi which is not an option for me.
    2: Change the parameters to Olevariants. This is what I am trying to do.
    I changed the class names in SAPbouiCOM_TLB to prevent naming problems
    TApplicationItemEvent --> TSUI_ApplicationItemEvent
    I changed my procedure declaration
    from:
    procedure SBO_Application_ItemEvent(ASender: TObject;
                                        const FormUID: WideString;
                                        var pVal: IItemEvent;
                                        out BubbleEvent: WordBool) of object;
    to:
    procedure SBO_Application_ItemEvent(ASender: TObject;
                                        const FormUID: OleVariant;
                                        var pVal: OleVariant;
                                        out BubbleEvent: OleVariant);
    This has to be changed in SAPbouiCOM_TLB to so I did
    from:
    TSUI_ApplicationItemEvent = procedure(ASender: TObject; const FormUID: WideString;
                                          var pVal: IItemEvent;
                                          out BubbleEvent: WordBool) of object;
    to:
    TSUI_ApplicationItemEvent = procedure(ASender: TObject; const FormUID: OleVariant;
                                          var pVal: OleVariant;
                                          out BubbleEvent: OleVariant) of object;
    Now the only thing there has to be done is changing the typecasting in TSUI_Application.InvokeEvent.
    Here a TVariantArray is converted to the WideString, IItemEvent and WordBool.
    And here is my problem. I don't know how to change this typecasting to OleVariants.
    procedure TApplication.InvokeEvent(DispID: TDispID; var Params: TVariantArray);
    begin
      case DispID of
        -1: Exit;  // DISPID_UNKNOWN
        100: if Assigned(FOnItemEvent) then
             FOnItemEvent(Self,
                          Params[0] {const WideString},
                          IItemEvent((TVarData(Params[1]).VPointer)^) {var IItemEvent},
                          WordBool((TVarData(Params[2]).VPointer)^) {out WordBool});
    How do I change IItemEvent((TVarData(Params[1]).VPointer)^) to the correct way?
    Thanks in advance,
    Sandra

    Hi
    I've got the Same Problem
    Has Anyone Fixed this problem.. Running Delphi 7 with SAP SBO 8.81 with the UI

  • Queue, Program speed on multiple Serial read and other problems

    Hi,
    Working on a relatively big program on Labview that makes
    1. data acquisition from 2xSerial devices
    2. Splitting the outputs,
    3. Showing the results
    4. Doing some alghorithms
    5. Outputing to CSVs.
    I have limited knowledge on serial methodologies and quequing in labview but through reading many posts in the forum i succeded to create this program which includes the above functions.
    Although that, I have several problems which I didnt solve:
    1. The quite button on the Graphs tab is not function correctly. This results in unabling to close the VISAs. How to handle the queques that in one button I can clear all the queques and exit the program correctly?
    2. While reading both serials, the program is going slow (I have i5 with SSD drive and 8gb RAM so I don't think its CPU problem). If I disable one of the serial or sending 'nothing' to one of the serials, the program going back to normal speed. Any suggestions in this issue?
    3. Both serials works with different configuration functions - I used that as I make a trial and error and this is the best operation for each of them. Is this correct or am I missing something?
    The main VI is "NVs_V1.6.vi"
    Thanks for your answers and feedback
    Sagi
    Attachments:
    Nvs.zip ‏973 KB

    You should only have 1 loop the dequeues from a specific queue.  Once an element is dequeued, that element is gone, meaning that no other loop can get that data.  You need to use a different queue for your two other loops.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Perl API: growing memory problem in loops over large sets of data

    Hi,
    When going through all XmlResults like this:
    while ($results->next($val)) {
    print $val->asString, "\n";
    The process size keeps growing. It does not when I comment $val->asString method out, but then I have no way of getting the results.
    This becomes a significant problem when the number of results is huge. I am doing this on a database of over a million short XML documents (400-800 bytes each).
    The more complete code is here:
    eval {
    $env = new DbEnv();
    $env->open($dbDir, Db::DB_JOINENV | Db::DB_INIT_LOCK
    | Db::DB_INIT_MPOOL | Db::DB_CREATE, 0);
    my $mgr = new XmlManager($env, DbXml::DBXML_ADOPT_DBENV);
    my $db = $mgr->openContainer(undef, $dbName, Db::DB_RDONLY);
    my $context = $mgr->createQueryContext(XmlQueryContext::LiveValues,
    XmlQueryContext::Lazy);
    my $lookup = $mgr->createIndexLookup($db, "", $nodeName,
    "node-$nodeType-equality-$syntax",
    new XmlValue($types{$nodeType}, $value), XmlIndexLookup::GTE);
    my $results = $lookup->execute(undef, $context);
    my $val = new XmlValue();
    while ($results->next($val)) {
    print $val->asString, "\n";
    if (my $e = catch std::exception) {
    die $e->what() . "\n";
    The process size just grows until the system limit is reached, then the process quits saying 'Out of memory'.
    I suspect the problem is with the std::string result returned by C++ XmlValue::asString() const.
    The (left-hand-side) result string is likely allocated by new std::string and receives the value by calling the string copy operator. Then the Perl scalar result is prepared, but when it gets returned to my code, the C++ string is not deleted.
    Moving the Sleepycat::XmlValue Perl object inside the loop does not help either:
    while ($results->hasNext()) {
    my $val = new XmlValue();
    $results->next($val);
    print $val->asString, "\n";
    In fact, the process seems to grow faster, possibly because the old $val instances do not get destroyed by Perl at the end of the loop. Where is Perl's garbage collection?
    I am using DB XML version: 2.2.13; BDB version: 4.4.20.2; OS: FreeBSD 6-STABLE. However the problem seems to be common for any OS or BDB XML version as it involves Perl-to-C++ interface.
    Has anyone experienced similar problems?
    Thanks,
    Konstantin.
    Konstantin @ Chuguev.com

    Good catch - you found a memory leak. Luckily the fix is very straightforward. Edit the file
    dbxml/src/perl/common.h
    and find this line
    #define newSVfromString(str) newSVpvn(str.c_str(), str.length())
    Change it to this
    #define newSVfromString(str) sv_2mortal(newSVpvn(str.c_str(), str.length()))
    and recompile the module.
    Paul

  • JES5 on HPUX C API Message Queue problem

    OK. I know there's not too many of you out there, but I've been trying to compile a simple "C" helloworld pub/sub application using GCC. The examples shows using 'aCC' instead of 'gcc' to compile on HPUX. I'm able to compile using gcc, but the application core dumps.
    Is the Message Queue, C-API & library compatable with applications compiled with gcc on the HPUX platform? Or will i have to use HP's Ascii C Compiler to get it to work.
    gcc build options:
    g++ -x c -fPIC -DHPUX11 -D_REENTRANT -I/opt/sun/mq/include -o Producer -L/opt/sun/mq/lib -L/opt/sun/private/lib -lnss3 -lmqcrt -Wl,+b,/opt/sun/private/lib Producer.c
    Error during execution:
    /usr/lib/dld.sl: Unresolved symbol: __shlinit (code) from /opt/sun/mq/lib/libmqcrt.sl
    Abort(coredump)
    Thanks
    Message was edited by:
    weinhard

    After switching to HP's ANSI C compiler i get the exact same error message.
    Any ideas as to what the permissions should be on the symbolic link to the real shared library. The installed permisstion/owners are:
    lrwxr-xr-x   1 bin        bin             29 Sep 12 00:45 libmqcrt.sl -> /opt/sun/mq/lib/libmqcrt.sl.1

  • Adobe Captivate 3 Serial Number/Windows 7 Problem

    Hi,
    Wonder if anyone on here could help me.  We have a volume license for Adobe Captivate 3 and it is installed and working fine on several XP machines.  However when I try and install the same software, with the same serial number that has been accepted everywhere else, but on a Windows 7 machine, it no longer see's the serial number as valid...
    Help!?
    Marky

    Hi there
    Sorry, but I'm not clear on what you want to know. Are you asking if moving to 5 from 3 is considered an upgrade and therefore qualifies for upgrade pricing from Adobe? If so, you will need to ask Adobe Sales on that. If you are asking about how to go about upgrading a Captivate 3 project so it becomes a Captivate 5 project, it's pretty tough to accomplish.
    First you have to open Captivate 5.
    Once Captivate 5 is open you open the Captivate 3 project.
    The Captivate 3 project is converted to a Captivate 5 project.
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • SUN MS-CAPI API  sign object problem

    I am using sun MS CAPI API and trying to sign the signature, I have attached the code, Code is giving me exception on the following line
    byte[] signature = sig.sign();
    The exception i am getting is saying that parameter is incorrect. Kindly help me on this issue, I have put in the exception below as well
    C:\Program Files\Java\jdk1.6.0_11\bin>java CapiLogin
    ---> alias : E-GOV TEST 10 22040000004
    Certificat : X.509
    Alias Key Matches
    privKey RSA
    Provider SunMSCAPI version 1.6
    java.security.SignatureException: The parameter is incorrect.
    at sun.security.mscapi.RSASignature.signHash(Native Method)
    at sun.security.mscapi.RSASignature.engineSign(RSASignature.java:252)
    at java.security.Signature$Delegate.engineSign(Signature.java:1128)
    at java.security.Signature.sign(Signature.java:522)
    at CapiLogin.signData(CapiLogin.java:86)
    at CapiLogin.main(CapiLogin.java:53)
    SGE MessageThe parameter is incorrect.
    Following is source code
    public static void main(String[] args) {
              // TODO Auto-generated method stub
              try{
              KeyStore ks = KeyStore.getInstance("Windows-MY");
              char[] pwd = new char[4];
              pwd[0] ='1';
              pwd[0] ='2';
              pwd[0] ='3';
              pwd[0] ='4';
              ks.load(null, pwd) ;
              java.util.Enumeration en = ks.aliases() ;
              byte[] data = { 65, 66, 67, 68, 69, 70, 71, 72, 73, 74 };
              while (en.hasMoreElements()) {
                   String aliasKey = (String)en.nextElement() ;
                   Certificate c = ks.getCertificate(aliasKey) ;
                   System.out.println("---> alias : " + aliasKey) ;
                   System.out.println(" Certificat : " + c.getType() ) ;
                   if (aliasKey.equals("E-GOV TEST 10 22040000004") ) {
                        System.out.println("Alias Key Matches") ;     
                   PrivateKey privKey = (PrivateKey)ks.getKey(aliasKey, null);
                   System.out.println("privKey " + privKey.getAlgorithm());     
                   // Certificate[] chain = ks.getCertificateChain(aliasKey);
                   Certificate cert = ks.getCertificate(aliasKey);
                   // System.out.println("cert " + cert);     
                   Provider p = ks.getProvider();
                   System.out.println("Provider " + p);
                   // signData(data,privKey );
                   Signature sig = Signature.getInstance("SHA1withRSA", p);
                   System.out.println("Signature " + sig);
                   sig.initSign(privKey);
                   System.out.println("Signature after signing " + sig);
                   System.out.println("Pvt Key is valid " );
                   sig.update(data);
                   System.out.println("Updated signed data " );
                   byte[] signature = sig.sign();
                   System.out.println("\tGenerated signature...");
                   sig.initVerify(cert);
                   sig.update(data);
                   if (sig.verify(signature)) {
                   System.out.println("\tSignature verified!");
         }catch(SignatureException sge){
              sge.printStackTrace();
              System.out.println("SGE Message" + sge.getMessage());
         }catch (Exception ioe) {
              System.out.println("Catch Exception");
              System.err.println(ioe.getMessage());
         }

    I just copied the code from signData(CapiLogin.java:86) into main function,
    Here is the updated Stack Trace with code
    import java.security.KeyStore;
    import java.security.PrivateKey;
    import java.security.Provider;
    import java.security.Signature;
    import java.security.SignatureException;
    import java.security.cert.Certificate;
    import java.security.spec.InvalidParameterSpecException;
    * @author muhammad.inam
    public class CapiLogin {
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              try{
              KeyStore ks = KeyStore.getInstance("Windows-MY");
              char[] pwd = new char[4];
              pwd[0] ='1';
              pwd[0] ='2';
              pwd[0] ='3';
              pwd[0] ='4';
              ks.load(null, pwd) ;
              java.util.Enumeration en = ks.aliases() ;
              byte[] data = { 65, 66, 67, 68, 69, 70, 71, 72, 73, 74 };
              while (en.hasMoreElements()) {
                   String aliasKey = (String)en.nextElement() ;
                   Certificate c = ks.getCertificate(aliasKey) ;
                   System.out.println("---> alias : " + aliasKey) ;
                   System.out.println("    Certificat : " + c.getType() ) ;
                   if (aliasKey.equals("E-GOV TEST 10 22040000004") ) {
                          System.out.println("Alias Key Matches") ;     
                         PrivateKey privKey = (PrivateKey)ks.getKey(aliasKey, null);
                         System.out.println("privKey " + privKey.getAlgorithm());     
                       //  Certificate[] chain = ks.getCertificateChain(aliasKey);
                         Certificate cert = ks.getCertificate(aliasKey);
                       //  System.out.println("cert " + cert);     
                         Provider p = ks.getProvider();
                         System.out.println("Provider " + p);
                        // signData(data,privKey );
                         Signature sig = Signature.getInstance("SHA1withRSA", p);
                         System.out.println("Signature " + sig);
                         sig.initSign(privKey);
                         System.out.println("Signature after signing " + sig);
                         System.out.println("Pvt Key is valid " );
                         sig.update(data);
                         System.out.println("Updated signed data " );
                         byte[] signature = sig.sign();
                         System.out.println("\tGenerated signature...");
                         sig.initVerify(cert);
                         sig.update(data);
                         if (sig.verify(signature)) {
                              System.out.println("\tSignature verified!");
         }catch(SignatureException sge){
              sge.printStackTrace();
              System.out.println("SGE Message" + sge.getMessage());
         }catch (Exception ioe) {
              System.out.println("Catch Exception");
              System.err.println(ioe.getMessage());
         public static byte[] signData(byte[] data, PrivateKey key) throws Exception {
             Signature signer = Signature.getInstance("RSA");
             signer.initSign(key);
             signer.update(data);
             return (signer.sign());
    }Stack Trace
    ---> alias : E-GOV TEST 10 22040000004
    Certificat : X.509
    Alias Key Matches
    privKey RSA
    Provider SunMSCAPI version 1.6
    Signature Signature object: SHA1withRSA<not initialized>
    Signature after signing Signature object: SHA1withRSA<initialized for signing>
    Pvt Key is valid
    Updated signed data
    java.security.SignatureException: The parameter is incorrect.
    at sun.security.mscapi.RSASignature.signHash(Native Method)
    at sun.security.mscapi.RSASignature.engineSign(RSASignature.java:252)
    at java.security.Signature$Delegate.engineSign(Signature.java:1128)
    at java.security.Signature.sign(Signature.java:522)
    at CapiLogin.main(CapiLogin.java:61)
    SGE MessageThe parameter is incorrect.

  • Changed mouse from serial to PS/2 problem...

    Hi all,
    I have changed from a serial mouse to a PS/2 mouse.
    How do I tell Solaris8 to work with that new mouse?
    Thanks a lot

    Check your F2...Set-Up Program...and if your PS/2 selection has a CHANGE---for...AT...that may work...for your USB-type Keyboard and Mouse...I prefer PS/2...the USB...Keyboard and Mouse that came with my DELL Purchase were small ITEMS...I switched over to PS/2 for a larger keyboard...BUT...F2...System Set-Up Program should have something for an AT-computer....<<---which is a USB-type Keyboard and Mouse.
    PORT Wine...!

Maybe you are looking for

  • Adobe Photoshop CS4:Setup dont start

    hello im from germany,sorry for my bad english i try to translate, i had download the trial version of CS4 and i want to install it but the setup exe dont run.when i click on it then nothing happens.when i click offten then comes a error message: "th

  • Saxophone sounds

    I am looking for some feedback/recommendations for good saxophone sounds for Logic. I am currently doing arrangements for a saxophone ensemble and need to produce good quality demos. The sounds that come with Logic are not very good. Can someone poin

  • InDesigns CS6 and CC Crash

    About every two months I have to uninstal and reinstal InDesign. It will crash when I open it and won't open again until I uninstal it and the reinstal it and then It'll work for roughly two months before I have to do it again. I had this problem wit

  • Master Detail Query automatic query ..Urgent help

    In my last question, I asked about how to automatically query a form based on table or master detail and gota good answer. What I actually need to do is also query on the detail, for example select a.user_id, b.week_ending,b.mon_hrs,b.tues_hrs from e

  • Missing Video in Clips

    I have problem... Premiere Pro CC, Viewing the source or assets are not working or not displaying, but just green screen (or blank screen).  How can I fix them out?  Thanks. [Please choose a short description for the thread title, and ask the questio