i have gp-ib card in pc connected dmm via gp-ib. have ran diagnostician on card , confirms working. able control threw there software test. trying create program it, when sends command gives error on dmm.
i have 3 source files master.pas, subclass.pas, , apigpib.pas
in master.pas have send command device.
var ret : dword; yradr : dword; srlen : dword; cmd : array[0..31] of dword; csbuf : string; /sending command device//////////////////////////////////////////////// procedure tformmaster1.buttonsendclick(sender: tobject); var srbuffer: string; // command sendbuf: pchar; begin yradr := strtoint(yradrbox.text); //card address srbuffer := editsenddata.text; srlen := length(srbuffer); // length of text sendbuf := pchar(srbuffer); // change string pchar if srlen <> $0 //string no empty begin // send command edittextret.text := 'waiting return???'; refresh(); cmd[0] := 2; // number of equipment talk cmd[1] := myadr; // device address cmd[2] := yradr; // card address ret := gptalk(@cmd, srlen, sendbuf); // sends address's, length, text checkret('gptalk', (ret , $ff), csbuf); // return value 255 length edittextret.text := csbuf; // return text end else edittextret.text := 'no text send'; end;
now in apigpib.pas have functions gptalk so.
type pdword=^dword function gptalk(cmd:pdword; srlen:dword; srbuf:pchar):dword;stdcall; ... ... ... implementation function gptalk; external 'apigpib1.dll' ;
it error out here on dmm, cant view apigpib1.dll.
- question is
+do see wrong logic?
+what can try in troubleshooting why dont work?
last of incase in checkret function. in subclass.pas have this.
type function checkret(func:string;ret:dword;var csbuf:string):dword; implementation function checkret(func: string; ret: dword; var csbuf: string):dword; var retcode,ret1: dword; begin retcode := 0; ret1 := ret , $ff; if ret1 >= 3 begin retcode := 1; case ret1 of 3: csbuf := func + ' : fifo“à‚É‚Ü‚¾ƒf[ƒ^‚ªŽc‚Á‚Ä‚¢‚Ü‚·b'; 80: csbuf := func + ' : i/oƒaƒhƒŒƒxƒgƒ‰[‚Å‚·b'; 82: csbuf := func + ' : ƒŒƒwƒxƒgƒŠÝ’è‚̃gƒ‰[‚Å‚·bconfig.exe‚ÅŠm”f‚µ‚Ä‚‚¾‚³‚¢b'; 128: csbuf := func + ' : Žómƒoƒbƒtƒ@‚ð’´‚¦‚½a‚Ü‚½‚Ísrq‚ðŽóm‚µ‚Ä‚¢‚Ü‚¹‚ñb'; 200: csbuf := func + ' : ƒxƒŒƒbƒh‚ªì¬‚Å‚«‚Ü‚¹‚ñb'; 201: csbuf := func + ' : ‘¼‚̃cƒxƒ“ƒgŠÖ”‚ªŽÀs’†‚Å‚·b'; 210: csbuf := func + ' : dma‚ªÝ’è‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½b'; 240: csbuf := func + ' : escƒl[‚ª‰Ÿ‚³‚ê‚Ü‚µ‚½b'; 241: csbuf := func + ' : ƒtƒ@ƒcƒ‹“üo—̓gƒ‰[‚Å‚·b'; 242: csbuf := func + ' : ƒaƒhƒŒƒxŽw’肪ŠÔˆá‚Á‚Ä‚¢‚Ü‚·b'; 245: csbuf := func + ' : ƒoƒbƒtƒ@‚ª¬‚³‚·‚¬‚Ü‚·'; 246: csbuf := func + ' : •s³‚ȃiƒuƒwƒfƒnƒg–¼‚Å‚·b'; 247: csbuf := func + ' : ƒfƒoƒcƒx–¼‚̉¡‚̃`ƒfƒbƒn‚ª–³Œø‚Å‚·b'; 248: csbuf := func + ' : •s³‚ȃf[ƒ^Œ^‚Å‚·b'; 249: csbuf := func + ' : ‚±‚êˆÈãƒfƒoƒcƒx‚ð’ljÁ‚Å‚«‚Ü‚¹‚ñb'; 250: csbuf := func + ' : ƒfƒoƒcƒx–¼‚ªŒ©‚‚©‚è‚Ü‚¹‚ñb'; 251: csbuf := func + ' : ƒfƒŠƒ~ƒ^‚ªƒfƒoƒcƒxŠÔ‚ňá‚Á‚Ä‚¢‚Ü‚·b'; 252: csbuf := func + ' : gp-ibƒgƒ‰[‚Å‚·b'; 253: csbuf := func + ' : ƒfƒŠƒ~ƒ^‚Ì‚Ý‚ðŽóm‚µ‚Ü‚µ‚½b'; 254: csbuf := func + ' : ƒ^ƒcƒ€ƒaƒeƒg‚µ‚Ü‚µ‚½b'; 255: csbuf := func + ' : ƒpƒ‰ƒ[ƒ^ƒgƒ‰[‚Å‚·b'; end; end else csbuf := func + ' : ³íi—¹‚µ‚Ü‚µ‚½b'; ret1 := ret , $ff00; case ret1 of $100: csbuf := csbuf + ' -- [srq]‚ðŽóm<status>'; // 10 -> [256] $200: csbuf := csbuf + ' -- [ifc]‚ðŽóm<status>'; // 10 -> [512] $300: csbuf := csbuf + ' -- [srq]‚Æ[ifc]‚ðŽóm<status>'; // 10 -> [768] end; result := retcode; end;
edit found gptalk function thats in dll. might find error?
format (c) dword srlen, ret; dword * cmd; char * srbuf; ret = gptalk(cmd, srlen, srbuf); (visual basic) dim srlen long, ret long dim cmd(xxxx) long '(xxxx specifies maximum number of command arrays.) dim srbuf string dim srbufb(xxxx) byte '(xxxx specifies maximum amount of data.) ret = gptalk(cmd(0), srlen, srbuf) ret = gptalkbinary(cmd(0), srlen, srbufb(0)) mode master mode/slave mode parameters cmd : [0] number of talkers , listeners ( = number of listeners+1) (slave mode = 0) [1] talker address [2] listener address srlen : transmit data length (byte) srbuf : transmit data srbufb : transmit data array(for binary) ret : return value 0 : normal completion 80 : gpini() hasn't execute 140 : asynchronous function executing 240 : esc key pressed 242 : miss in address specified 243 : miss in buffers 252 : gp-ib error 254 : timeout 255 : illegal call notes 1 command array: since number of commands sent given cmd[0], specify 0 cmd[0] in slave mode. 2 1mbyte sent if transmit data length = 0. 3 if have used dos-version, not need execute dmainuse function when using fifo. 4 when transmits binary data vb, use gptalkbinary. , secure buffers byte type. refer vb's "unicode".
- in d10-seattle have use
pansichar
,ansistring
data buffers
(becausepchar
pwidechar
in modern delphi versions). - does gptalk return data
srbuf
? if so, buffer length enough response?
.
srbuffer: ansistring; // command sendbuf: pansichar; ... sendbuf := pansichar(srbuffer); // change string pchar ... function gptalk(cmd:pdword; srlen:dword; srbuf: pansichar):dword;stdcall;
Comments
Post a Comment