I just spent a frustrating afternoon trying to fix a problem in someone else's code written in Delphi 5 (I know it's ancient, but there are good reasons why it hasn't been upgraded).
I had a modal form that was displayed using ShowModal and when a comms error occured I set ModalResult to mrAbort expecting the form to close, but it wouldn't.
The form uses a serial port component (see http://comport.sf.net/ ) and has an OnRxChar callback on the serial port component set up to process characters. The OnRxChar callback is set to a method of the modal form. It turns out that the window won't close until you "unhook" the callback so I had to do the following to get it to close :
// Close the form when an error occurs
procedure TGetFilesForm.Stop;
begin
// Must get rid of the rx callback, otherwise
// the form won't close
if _comport <> nil then
_comport.OnRxChar := nil;
ModalResult := mrAbort;
end;
Tuesday, August 25, 2009
Wednesday, August 12, 2009
Convert Postscript to PDF
To get my gschem circuit schematics in PDF I print them from gschem to a Postscript file and then convert the Postscript file to PDF using gs, as follows:
gs -q -dSAFER -dNOPAUSE -dBATCH -sOutputFile=circuit.pdf -sDEVICE=pdfwrite -f circuit.ps
gs -q -dSAFER -dNOPAUSE -dBATCH -sOutputFile=circuit.pdf -sDEVICE=pdfwrite -f circuit.ps
Export gEDA PCB layout to DXF
I am using gEDA PCB to layout a circuit board and needed to export the layout to a DXF file so that the mechanical designer can check it against the plastic housing design. Here's what you do:
1. Export the layout form PCB to Postscript- tick the "multiple files" box so that each page is a separate Postscript file
2. Merge the Postscript files with the outline and assembly with psmerge - "psmerge -opcb.ps pcb.outline.ps pcb.frontassembly.ps"
3. Convert the Postscript file to DXF with pstoedit - "pstoedit -f dxf pcb.ps pcb.dxf"
I usually print out the Postscript file to check the footprints I am using against the actual parts I am using. Note that this does not work if you convert the Postscript files to PDF - you seem to then have a file that does not print out to scale.
1. Export the layout form PCB to Postscript- tick the "multiple files" box so that each page is a separate Postscript file
2. Merge the Postscript files with the outline and assembly with psmerge - "psmerge -opcb.ps pcb.outline.ps pcb.frontassembly.ps"
3. Convert the Postscript file to DXF with pstoedit - "pstoedit -f dxf pcb.ps pcb.dxf"
I usually print out the Postscript file to check the footprints I am using against the actual parts I am using. Note that this does not work if you convert the Postscript files to PDF - you seem to then have a file that does not print out to scale.
Wednesday, August 5, 2009
Blogging as a personal notebook
I thought I might try this new-fangled blogging thing to see if it is a good way to keep track of useful bits of information, particularly related to my work.
I work with Embedded Systems (electronics and software) so I am continuously finding out new bits of information on hardware or software that I will want to remember some day.
I work with Embedded Systems (electronics and software) so I am continuously finding out new bits of information on hardware or software that I will want to remember some day.
Subscribe to:
Posts (Atom)