全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2587
推到 Plurk!
推到 Facebook!

電腦與電腦間的GPIB通訊問題

答題得分者是:aki0921
esju0000
一般會員


發表:7
回覆:9
積分:3
註冊:2007-09-01

發送簡訊給我
#1 引用回覆 回覆 發表時間:2010-05-21 17:44:32 IP:60.249.xxx.xxx 訂閱
之前爬文GPIB的通訊
大都只找到電腦與設備通訊
沒找到電腦與電腦通訊的相關文章
手上只有NI提供的範例
編譯後仍無法進行通訊
還呈現死當的'狀態
應該是卡死在WHILE LOOP裡
主要的原因應該是電腦間彼此抓取不到彼此
麻煩大家指點一下迷津
範例如下:

[code cpp]
static int noncontroller;
static char buffer[100];
void __fastcall TForm1::Button1Click(TObject *Sender)
{
// Open a session to the GPIB board
noncontroller = ibfind ("gpib0");
// Release system control
ibrsc (noncontroller, 0);
// Change primary address from 0 to 1
ibpad (noncontroller, 1);
if (RadioButton1->Checked == true)// Controller
ibdev (0, 1, 0, 13, 1, 0);

}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
String DataWrite = Edit2->Text;
while (1)
{
// Update Status variable
ibwait (noncontroller, 0);
// If addressed to talk, send the response "I am a talker"
if ((ibsta&TACS)&&(!(ibsta&ATN)))
{
// Send data across the bus.
ibwrt (noncontroller, DataWrite.c_str(), strlen(DataWrite.c_str()));
break;
} // second if
} // while
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
while (1)
{
// Update Status variable
ibwait (noncontroller, 0);
// Wait until non-controller is listener and ATN line is dropped.
if ((ibsta&LACS)&&(!(ibsta&ATN)))
{
ibrd (noncontroller, buffer, 100); // Read data bytes
buffer[ibcnt] = '\n'; // Add linefeed and 0 to string.
buffer[ibcnt 1] = 0;
printf ("%s",buffer); //print buffer
Edit1->Text = buffer;
break;
} // first if
} // while
}

[/code]

aki0921
一般會員


發表:13
回覆:11
積分:14
註冊:2007-12-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2010-06-21 11:11:36 IP:60.251.xxx.xxx 訂閱
NI的儀器應該會有提供他的tool
你要先用它的軟體找看看跟你連接的設備存不存在,
在查看他的id編號是幾號,
說不定你寫的13是不對的。
===================引 用 esju0000 文 章===================
之前爬文GPIB的通訊
大都只找到電腦與設備通訊
沒找到電腦與電腦通訊的相關文章
手上只有NI提供的範例
編譯後仍無法進行通訊
還呈現死當的'狀態
應該是卡死在WHILE LOOP裡
主要的原因應該是電腦間彼此抓取不到彼此
麻煩大家指點一下迷津
範例如下:

[code cpp]
static int noncontroller;
static char buffer[100];
void __fastcall TForm1::Button1Click(TObject *Sender)
{
// Open a session to the GPIB board
noncontroller = ibfind ("gpib0");
// Release system control
ibrsc (noncontroller, 0);
// Change primary address from 0 to 1
ibpad (noncontroller, 1);
if (RadioButton1->Checked == true)// Controller
ibdev (0, 1, 0, 13, 1, 0);

}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
String DataWrite = Edit2->Text;
while (1)
{
// Update Status variable
ibwait (noncontroller, 0);
// If addressed to talk, send the response "I am a talker"
if ((ibsta&TACS)&&(!(ibsta&ATN)))
{
// Send data across the bus.
ibwrt (noncontroller, DataWrite.c_str(), strlen(DataWrite.c_str()));
break;
} // second if
} // while
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
while (1)
{
// Update Status variable
ibwait (noncontroller, 0);
// Wait until non-controller is listener and ATN line is dropped.
if ((ibsta&LACS)&&(!(ibsta&ATN)))
{
ibrd (noncontroller, buffer, 100); // Read data bytes
buffer[ibcnt] = '\n'; // Add linefeed and 0 to string.
buffer[ibcnt 1] = 0;
printf ("%s",buffer); //print buffer
Edit1->Text = buffer;
break;
} // first if
} // while
}

[/code]

系統時間:2024-04-27 0:20:17
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!