最新版はこちら。 突っ込みは各日付の BBS エントリのほか、 メール (nakano@st.seikei.ac.jp) や フォーム からどうぞ。 なおスパム除けのため、BBS 機能には 緩い認証を入れて います。 検索エンジンから来た方は、エンジンの方のキャッシュを見るか、 下の簡易検索を試してみてください。
|
Namazu for hns による簡易全文検索 詳しくは 詳細指定/ヘルプを参照して下さい |
|||||||||||||||||||||||||||||||||||||||||||||||
0xAA 0xAA 0xAB ...の形式なので、簡単に scanf できるかと思っていたんだけど。
Public Class Form1 Inherits System.Windows.Forms.Form Dim defrm As Integer Dim vi As Integer Dim g As Graphics (フォームデザイナで生成されたコード) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim status As Integer Dim dsoaddr As String = "GPIB0::7::INSTR" Dim idnreply As System.Text.StringBuilder = New System.Text.StringBuilder(256) g = PictureBox1.CreateGraphics status = visa32.viOpenDefaultRM(defrm) status = visa32.viOpen(defrm, dsoaddr, 0, 0, vi) visa32.viPrintf(vi, "*IDN?" & vbLf) visa32.viScanf(vi, "%s", idnreply) Label1.Text = idnreply.ToString visa32.viPrintf(vi, ":WAV:SOUR CHAN1" & vbLf) End Sub Private Sub form1_closing(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Closed Call visa32.viClose(vi) Call visa32.viClose(defrm) End Sub Private Sub ButtonFetch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonFetch.Click Dim vierror As Integer Dim i As Integer Dim maxpcount As Integer = 1300 Dim maxbcount As Integer = maxpcount * 5 Dim pcount As Integer Dim bcount As Integer Dim readbuf(maxbcount) As Byte Dim pval(maxpcount) As Integer Dim strdata As String visa32.viPrintf(vi, ":WAV:DATA?" & vbLf) vierror = visa32.viRead(vi, readbuf, maxbcount, bcount) If vierror < visa32.VI_SUCCESS Then Dim err As System.Text.StringBuilder = New System.Text.StringBuilder(256) visa32.viStatusDesc(vi, vierror, err) Label1.Text = err.ToString Else Label1.Text = bcount.ToString & "chars read." End If For i = 0 To bcount - 1 strdata = strdata & Chr(readbuf(i)) Next Dim spos As Integer = 1 i = 0 Do Dim tmpstr As String spos = spos + 2 tmpstr = Mid(strdata, spos, 2) pval(i) = Convert.ToInt32(tmpstr, 16) i = i + 1 spos = InStr(spos, strdata, "0x") Loop While spos > 0 pcount = i Dim xs As Integer, xe As Integer For i = 0 To pcount - 2 xs = Int(i / 3) xe = Int((i + 1) / 3) g.DrawLine(Pens.Red, xs, pval(i), xe, pval(i + 1)) Next End Sub End Class絵としては こんな 感じ で (注:ぜんぜん面白くありません)。