Can't open serial port with PICED

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by gotliebk, Jun 9, 2009.

  1. gotliebk

    gotliebk

    Joined:
    Feb 13, 2009
    Messages:
    14
    Likes Received:
    0
    I'm trying to write a custom serial driver for a Color Kinetics LED controller (iW Translator) and I can't get PICED to open up my COM port. Currently, the iW Translator is hooked directly from my COM1 to it's serial port.

    I get the following error message from the OpenSerial command in the Initilisation section.

    Logic Run-time Error R100 at line 60:0 - Other error (SetCommState function failed (win error code: 87))

    The command at line 60:0 is this..

    OpenSerial(1,1,9600,8,scNoParity,scOneStopBit,scNoFlowControl);

    I have verified that COM1 works on my PC by using Hyperterminal. I can send commands and get acks from the iW Translator using Hyperterminal. I'm using Free Serial Port Monitor to watch the commands go back and forth. I shut HyperTerminal down and run my PICED code, the Monitor says that PICED opened the comm port successfully and then closed it right back down.

    I haven't even hooked up the PAC yet, so please think hard on what could be causing PICED to be unable to open my COM port. I can't see it. Am I reading the OpenSerial documentation wrong? I should be able to test and debug my driver in PICED and then load it up on my PAC, right? Or is the OpenSerial procedure only available on the PAC itself? What about the SetCommState function? I can't find any docs on it at all.

    Any constructive thoughts are greatly appreciated.


    I'm running Windows XP Pro SP2 on a Dell Latitude D630.
    PICED 4.6.1 just installed.

    Here is the complete code:

    Logic Program
    Constants

    {Intensities}
    MaxIntensity = '06';
    MidIntensity = '03';
    MinIntensity = '00';

    {Color Temps }
    WarmestTemp = '00';
    MiddleTemp = '03';
    CoolestTemp = '06';

    {Times}
    Instant = '00';
    HalfSecond = '16';
    OneSecond = '32';
    TwoSecond = '64';
    ThreeSecond = '96';
    FourSecond = 'C8';

    {Commands}


    Types
    {Enter Type definitions here}


    Variables
    {Enter Variable definitions here}

    IW_LED1_Intensity : integer ;
    IW_LED1_Color : integer ;
    IW_LED1_Zone : integer ;
    IW_LED1_Ramp : integer ;


    stCommand : string;
    stIntensity : string;
    stColorTemp : string;
    stTime : string;
    stZone : string;
    stRamp : string;


    I : integer; {Intensity Counter}
    C : integer; {Color Temp Counter}

    Procedures
    Functions
    Initialisation
    {Enter Initialisation code here}

    IW_LED1_Intensity := 0;
    IW_LED1_Color := 0;
    IW_LED1_Zone := 0 ;
    IW_LED1_Ramp := 0 ;

    OpenSerial(1,1,9600,8,scNoParity,scOneStopBit,scNoFlowControl);







    Module "Test Serial"
    {Test serial comms with Com 1}

    begin


    for I := 0 to 6 do
    for C := 0 to 6 do
    begin
    stCommand := 'X10'; {Build the intensity set string and send it}
    IntToHexString(2, 0, stZone); {Zone}
    append(stCommand,stZone);

    IntToHexString(I, 0, stIntensity);
    append(stCommand,stIntensity);

    IntToHexString(0, 0, stRamp);
    append(stCommand,stRamp);

    WriteSerial(1,stCommand);

    stCommand := 'X11';
    append(stCommand,stZone);

    IntToHexString(C, 0, stColorTemp);
    append(stCommand,stColorTemp);

    append(stCommand,stRamp);

    WriteSerial(1,stCommand);

    end;



    end;
     
    gotliebk, Jun 9, 2009
    #1
  2. gotliebk

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,420
    Likes Received:
    62
    Location:
    Adelaide
    Is that space in "scNo FlowControl" above actually there in your code?

    In my version (4.6.1) that line doesn't even compile... it's meant to be "scNoFlowControl".

    Nick
     
    NickD, Jun 9, 2009
    #2
  3. gotliebk

    gotliebk

    Joined:
    Feb 13, 2009
    Messages:
    14
    Likes Received:
    0
    Nick,

    I'm not sure why there is a space shown in the code above. There is no space in the actual code I'm running. I get the same error if I replace the Constant Name scNoFlowControl with a 0. Thanks for looking over my syntax.

    If you take out the space, does it run on your computer?
     
    gotliebk, Jun 9, 2009
    #3
  4. gotliebk

    gotliebk

    Joined:
    Feb 13, 2009
    Messages:
    14
    Likes Received:
    0
    Self Answered

    For anyone else that runs into this, I found the answer. The OpenSerial command does not work in Piced to open the PC serial port. You can only use it on the PAC itself. This is a problem when troubleshooting a custom serial driver as you have to do a lot of downloading and tweaking of the PAC before you get it right. It would be nice if this routine actually could be made to work in PICED for troubleshooting purposes.
     
    gotliebk, Jun 24, 2009
    #4
  5. gotliebk

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    I've never had a problem opening a serial port in PICED on the PC. You may be trying to open a non-existent port, or one that is assigned by another device.
     
    Ashley, Jun 24, 2009
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.