Bytetostr - hangs
WordToStr - hangs
//non-MKP Conversion
Byte2StrN - hangs
Word2strN - only conversion that does not hang in this loop
I do not have a problem anywhere else in the code, but then this is the only code where I have a loop using the conversion twice in the same repeat loop.
I have submitted this problem with a file under ticket QXL-696258
For those interested, Here is the code; First is the Main program followed by a needed Unit of variables and record definitions
Code: Select all
program Test_Byte;
uses EIC_Variables;
Procedure Initialize;
begin
R_ConfigRPM.User_Max_Value := 20;
end;
Procedure Config_Send_to_Pmag;
begin
nop;
end;
Procedure Store_Pmag_Configuration ;
begin
nop;
end;
Procedure Config_To_PMag; //This sends the selected Pmag configuration in EIC to Pmag over Rs232 link
//and sets Last_used_Flag in EEPROM
Var
Cmd_Value_Str:string[2];
Hexstring1:string[2];
Lengthx:byte;
i:byte; //index for FOR loop
Value:byte;
ValueI:integer;
Send_times:byte;
Save1_Channel:byte;
begin
send_Times := 0;
i := 1;
if save_Channel = 3 then
begin
Channel := 1; //if dual then change to first channel 1 (right) and then Channel 2 (left) channel reset to 2 at bottom of For statement
send_Times := 3; //send it twice, 2nd time to channel 2 (left)
end
else
Send_Times := 1; //send once to channel 1
Repeat
//*********** Max RPM Change to EPI **************
MaxRPMdata1.raw := R_ConfigRPM.User_Max_Value ; //From EEPROM or Changes made to Configuration record values
Save_RPM_Max := R_ConfigRPM.User_Max_Value * 256; //* 256 to turn Raw rpm Value into display Value //save for comparison of changed config on the fly //From EEPROM or Changes made to Configuration record values
Value := R_ConfigRPM.User_Max_Value ;
//************** PROBLEM AREA *******************************************
// bytetostr(Value, Hexstring1); //All three of these converstions to string
//Wordtostr(Value, Hexstring1); // cause program to hang here
//*********** used different conversion library in attempt to get coversion to work - I think you will recognize it
//Byte2strN(value,Hexstring1,2);
word2strN(value,Hexstring1,2); //This is the only conversion that does not hang
Cmd_Value_Str := '/M' ;
strcat( Cmd_Value_Str,HexString1);
Txbuff1 := Cmd_Value_Str;
Lengthx := Strlen(Txbuff1);
Txbuff1[Lengthx] := $0D;
Config_Send_to_Pmag;
Delay_MS(50); // 20 May 2011 1 Apr was 100}
channel := 2; // Set to channel 2 Left for second transmission to left pmag if required
Store_Pmag_Configuration; // 1 Dec 2010 //stores Sent Configuration "permanently' in EPI Flash Memory
Config_Send_to_Pmag;
if i = 2 then Delay_MS(250); //delay between right and left Pmags only if dual
inc(I);
until ( I >= Send_Times); //if single channel send_times = 1 , I =2 so exits, If Send_Times =3 then loop repeats a second time
nop; //In Debug run to cursor here
end;
begin
Initialize;
save_Channel := 3;
Config_To_PMag;
end.
Code: Select all
Unit EIC_Variables;
Type Static = Record
Text1:string[4]; // 5 Nov was string[4];
Raw :integer; // 1 Apr
Value :dword;
end;
//Type for RPM and Hobbs configuration Record (1st line in EEPROM)
Type
ConfigRpm = Record //For Tach configuration
Config_Name:String[5];//name of configuration file
Param_Name :char;//Name of paramter of which value is to be changed
Tach_PPR:byte;//pulses per rev
User_Max_Value:word; //adjustable by user within Max_Value_LimitUsed for passing parmaters to adjustment of configuration values
User_Min_Value:word; //adjustable by user within min_value_Limit
Max_Value_Limit:word; //Not adjustable by user pull from EEPROM when in Adjust Mode
Min_Value_Limit:word; //Not adjustable by user Store to EEPROM when leaving Adjust Mode
Rpm_Caution_Lower1:word; //These are set by user to provide warning when operating in a restricted rpm band
Rpm_Caution_Higher1:word;
Rpm_Caution_Lower2:word;
rpm_caution_Higher2:word;
Hobbs_Limit:word; //sets the rpm above which the Hobbs keep time
Hobbs_Start_Time:dword; // 29 May sets initial value of hobbs meter if different than zero
Caution_LED:byte;//Flag which turns on/off Yellow Caution LED - can not turn of RED Alarm LED
Fast_Rate :byte; //Maximum step size of value changed to word to accomodate 256 byte step
Slow_Rate :byte; //min stemp sixe of value
Pause :byte; //number of counts before pushed button clicks into fast mode
end;
const size1:byte = 24; // 19 May 2011 15 Mar 2011 20 Feb 2011 was 26 size for Rx and Hexstring
ConvFactor = 1.401; // 19 May 2011
Var //Variable for Emag RxBuf handling
Txbuff1 :string[size1];Volatile;//array[size1] of char;
//***********RECORD TYPE ASSIGNMENT ***************************************
//Set up proper record types for keeping data - Static or Stream
PropData1 :Static;//PropData;
PropData2 :Static;
conshiftData1 :Static;//:SmallRecData;
conshiftData2 :Static;//:SmallRecData;
eicad :Static;//SmallRecData;
RevData1 :Static;//:SmallRecData;
RevData2 :static;
Leddata1 :Static;//:smallRecData;
LedData2 :static;
pprdata1 :Static;
pprdata2 :static;
maxrpmdata1 :Static;
Maxrpmdata2 :static;
maxadvdata1 :Static;
Maxadvdata2 :static;
CpuTempData1 :Static;
CpuTempData2 :Static;
CycleData1 :Static;
CycleData2 :Static;
runtimehour1 :Static;//SmallRecData; //Text field is for hours
runtimehour2 :Static;
//********** FOR VALUE CHANGE AND CONFIGURATION **************************
Type
Config = Record
Config_Name:String[5];//name of configuration file
Param_Name :char;//Name of paramter of which value is to be changed
Raw :word;
User_Max_Value:word; //adjustable by user within Max_Value_LimitUsed for passing parmaters to adjustment of configuration values
User_Min_Value:word; //adjustable by user within min_value_Limit
Max_Value_Limit:word; //Not adjustable by user pull from EEPROM when in Adjust Mode
Min_Value_Limit:word; //Not adjustable by user Store to EEPROM when leaving Adjust Mod
Fast_Rate :byte {word}; //Maximum step size of value
Slow_Rate :byte; //min stemp sixe of value
Pause :byte; //number of counts before pushed button clicks into fast mode
Last_used_Flag:byte;
end;
Type //Record for Intergal Type Configuration Data
ConfigI = record
Config_Name:String[5];
Param_Name :char;
//Current_ValueI :integer; //Current value
User_max_ValueI:integer;
User_Min_ValueI:integer;
Max_Value_LimitI :integer; //Max Value
Min_Value_LimitI :integer;
Fast_Rate :byte; //Maximum step size of value
Slow_Rate :byte; //min stemp sixe of value
Pause :byte; //number of counts before pushed button clicks into fast mode
// Last_used_Flag:byte;
end;
var R_ConfigRPM:config; //records for configurations Stored in EEPROM
Save_RPM_Max:word;
Save_Channel:byte;
channel:byte;
implementation
end.