gotliebk
09 Jun 09, 05:43 PM
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,scNo FlowControl);
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,scNo FlowControl);
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;
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,scNo FlowControl);
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,scNo FlowControl);
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;