Changeset 417
- Timestamp:
- Aug 20, 2012, 2:47:30 PM (12 years ago)
- Location:
- ISPProgrammer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ISPProgrammer/Dallas/UDallasProgrammer.pas
r413 r417 9 9 UJobProgressView, SyncObjs, DateUtils, Dialogs, URegistry, 10 10 Forms, UISPProgrammer, Registry, UBinarySerializer, SpecializedList, 11 UCommTelnet ;11 UCommTelnet, UCommTCPClient, UCommTelnetComPortOption, UCommConnector; 12 12 13 13 const … … 27 27 ResponseLock: TCriticalSection; 28 28 ResponseTemp: TBinarySerializer; 29 SerialPortBackup: TCommSerialPort;30 SerialPortBackupPin: TCommPin;29 ConnectorBackup: TDeviceConnector; 30 ConnectorBackupPin: TCommPin; 31 31 HexData: TStringList; 32 32 Request: TBinarySerializer; … … 36 36 function ResponseCount: Integer; 37 37 procedure ResponseClear; 38 procedure CheckErrorCode(Value: string); 38 procedure CheckWriteErrorCode(Value: string); 39 procedure CheckResponseErrorCode(Value: string); 39 40 protected 40 41 procedure SetActive(AValue: Boolean); override; … … 43 44 Identification: string; 44 45 BaudRate: Integer; 46 Connector: TDeviceConnector; 45 47 procedure LoadFromRegistry(Root: HKEY; Key: string); override; 46 48 procedure SaveToRegistry(Root: HKEY; Key: string); override; … … 139 141 SerialPort: TCommSerialPort; 140 142 Telnet: TCommTelnet; 143 TelnetOption: TTelnetOptionComPort; 141 144 begin 142 145 if Active = AValue then Exit; … … 148 151 HexData := TStringList.Create; 149 152 150 if ExtPin.Connected and (ExtPin.RemotePin.Node is TCommSerialPort) then begin 151 SerialPort := TCommSerialPort(ExtPin.RemotePin.Node); 152 SerialPort.Active := False; 153 SerialPortBackup.Assign(SerialPort); 154 SerialPortBackupPin := SerialPort.Pin.RemotePin; 155 SerialPort.Pin.Disconnect; 156 153 Connector.Active := False; 154 ConnectorBackup.Assign(Connector); 155 ConnectorBackupPin := Connector.Pin.RemotePin; 156 Connector.Pin.Disconnect; 157 if Connector.ConnectionType = ctSerialPort then begin 157 158 //SerialPort.Name := SerialPort.Name; 158 SerialPort.SerialPort.FlowControl := fcNone; 159 SerialPort.SerialPort.BaudRate := BaudRate; 160 SerialPort.SerialPort.DTR := True; 161 SerialPort.Pin.Connect(CommMark.PinRaw); 162 SerialPort.SerialPort.Flush; 163 SerialPort.SerialPort.Purge; 164 SerialPort.Active := True; 165 if Assigned(FOnLogData) then 166 Pin.OnLogData := FOnLogData; 167 end; 168 if ExtPin.Connected and (ExtPin.RemotePin.Node is TCommTelnet) then begin 169 Telnet := TCommTelnet(ExtPin.RemotePin.Node); 170 end; 159 Connector.CommSerial.SerialPort.FlowControl := fcNone; 160 Connector.CommSerial.SerialPort.BaudRate := BaudRate; 161 Connector.CommSerial.SerialPort.DTR := True; 162 Connector.CommSerial.SerialPort.Flush; 163 end else 164 if Connector.ConnectionType = ctNetworkClient then begin 165 TelnetOption := TTelnetOptionComPort(Connector.CommTelnet.SearchOption(tmComPortControlOption)); 166 TelnetOption.FlowControl := fcNone; 167 TelnetOption.BaudRate := BaudRate; 168 TelnetOption.DTR := True; 169 end; 170 Connector.CommSerial.SerialPort.Purge; 171 Connector.CommTelnet.Purge; 172 Connector.Pin.Connect(CommMark.PinRaw); 173 if Assigned(FOnLogData) then 174 Pin.OnLogData := FOnLogData; 175 CommMark.Active := True; 176 Connector.Active := True; 171 177 ResponseClear; 172 CommMark.Active := True;178 Sleep(1000); 173 179 ReadIdentification; 174 180 end else begin 175 181 CommMark.Active := False; 176 if ExtPin.Connected and (ExtPin.RemotePin.Node is TCommSerialPort) then begin 177 SerialPort := TCommSerialPort(ExtPin.Node); 178 SerialPort.Active := False; 179 SerialPort.Assign(SerialPortBackup); 180 SerialPort.Pin.Connect(SerialPortBackupPin); 181 SerialPort.Active := True; 182 end; 183 if ExtPin.Connected and (ExtPin.RemotePin.Node is TCommTelnet) then begin 184 Telnet := TCommTelnet(ExtPin.RemotePin.Node); 185 end; 182 Connector.Active := False; 183 Connector.Assign(ConnectorBackup); 184 Connector.Pin.Connect(ConnectorBackupPin); 185 Connector.Active := True; 186 186 HexData.Free; 187 187 Request.Free; … … 189 189 end; 190 190 191 procedure TDallasProgrammer.Check ErrorCode(Value: string);191 procedure TDallasProgrammer.CheckWriteErrorCode(Value: string); 192 192 begin 193 193 if Value = 'H' then raise Exception.Create(SInvalidHexFormat) … … 203 203 end; 204 204 205 procedure TDallasProgrammer.CheckResponseErrorCode(Value: string); 206 begin 207 if Value <> '' then begin 208 if Value[1] = 'E' then 209 raise Exception.Create('Dallas error: ' + Value); 210 end; 211 end; 212 205 213 procedure TDallasProgrammer.LoadFromRegistry(Root: HKEY; Key: string); 206 214 begin … … 239 247 Pin.Send(Request.List); 240 248 Value := ReadResponse; 241 ReadResponse; // Empty line 249 Value := ReadResponse; // Empty line 250 CheckResponseErrorCode(Value); 242 251 243 252 //HexFile.SaveToStringList(HexData); … … 287 296 Pin.Send(Request.List); 288 297 Value := ReadResponse; 289 Check ErrorCode(Value);298 CheckWriteErrorCode(Value); 290 299 Job.Progress.Value := I; 291 300 if Job.Terminate then Break; … … 319 328 Pin.Send(Request.List); 320 329 Value := ReadResponse; 321 Check ErrorCode(Value);330 CheckWriteErrorCode(Value); 322 331 Job.Progress.Value := I; 323 332 if Job.Terminate then Break; … … 335 344 Request.WriteByte(Ord('K')); 336 345 Pin.Send(Request.List); 337 ReadResponse;346 CheckResponseErrorCode(ReadResponse); 338 347 end; 339 348 … … 354 363 Request.Clear; 355 364 Pin.Send(Request.List); 356 ReadResponse; // Empty line365 Value := ReadResponse; // Empty line 357 366 Identification := ReadResponse; 358 Result := Identification; 367 359 368 Log(SIdentification + ': ' + Identification); 360 369 end; … … 378 387 CommMark.PinFrame.Connect(Pin); 379 388 BaudRate := 9600; 380 SerialPortBackup := TCommSerialPort.Create(nil);389 ConnectorBackup := TDeviceConnector.Create; 381 390 end; 382 391 … … 384 393 begin 385 394 Active := False; 386 Mark.Free;387 CommMark.Free;388 SerialPortBackup.Free;389 Pin.Free;390 ResponseQueue.Free;391 ResponseLock.Free;392 ResponseTemp.Free;393 inherited Destroy;395 FreeAndNil(Mark); 396 FreeAndNil(CommMark); 397 FreeAndNil(ConnectorBackup); 398 FreeAndNil(Pin); 399 FreeAndNil(ResponseQueue); 400 FreeAndNil(ResponseLock); 401 FreeAndNil(ResponseTemp); 402 inherited; 394 403 end; 395 404 -
ISPProgrammer/PRESTO/UPresto.pas
r414 r417 8 8 9 9 uses 10 Classes, SysUtils, UISPProgrammer, UPrestoDLL, 10 Classes, SysUtils, UISPProgrammer, UPrestoDLL, UCommPin, 11 11 UStreamHelper, Globals, Processors, Delays, UCPUType, Registry, 12 12 UJobProgressView; -
ISPProgrammer/UISPProgrammer.pas
r414 r417 32 32 FileName: string; 33 33 Capabilities: TISPProgCapabilities; 34 ExtPin: TCommPin;35 34 procedure Log(Text: string); 36 35 procedure LoadFromRegistry(Root: HKEY; Key: string); virtual; … … 130 129 constructor TISPProgrammer.Create; 131 130 begin 132 ExtPin := TCommPin.Create;131 //ExtPin := TCommPin.Create; 133 132 HexFile := TIntelHexFile.Create; 134 133 HexFile.BytePerLine := 20; … … 138 137 begin 139 138 Active := False; 140 FreeAndNil(ExtPin);139 //FreeAndNil(ExtPin); 141 140 FreeAndNil(HexFile); 142 141 inherited Destroy;
Note:
See TracChangeset
for help on using the changeset viewer.