X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 08 Jan 2008 09:47 AM by  anon
How to use serial.dlm(dll) for control the device via RS 232?
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
08 Jan 2008 09:47 AM
    We need your help about the serial.dll. (Currently, I use window XP and IDL 6.3) We downloaded serial.dll from RSI and placed it right folder(C:\\RSI\idl6.3\bin\bin.x86). Now, we need some examples how to use it for control the device via RS232. This is the first time to use IDL to control the device. We have tested via hyper terminal to control the device and it is working well. If anyone has or know any example or reference for this task, please let me know...Thanks.

    Deleted User



    New Member


    Posts:
    New Member


    --
    08 Jan 2008 09:47 AM
    'serial.dll' is a fairly low-level library that is designed to do just four things: 1) Open a connection to a com serial port, e.g.: ; Open an RS232 connection on COM port 1 in Read/Write mode with 19200 baud rate, ; interpreting data as 7-bit values, using odd parity and 2 stop bits comPortHandle = COMM_OPEN('COM1', BAUD=19200, DATA=7, $ MODE=3, PARITY='O', STOP=2 2) Write raw binary data to the port after connection data = byte('Hello') nBytesWritten = WRITE_COMM(comPortHandle, data) if nBytesWritten ne 5 then print, 'ERROR: Not all bytes were sent!' 3) Read raw binary data from the port after connection messageBuffer = bytarr(1024) offset = 0 nBytes = COMM_READ(comPortHandle, BUFFER=messageBuffer, $ NMAX=n_elements(messageBuffer) ; Let's say we are expecting a 36-byte message offset += nBytes if offset lt 36 then $ nBytes = COMM_READ(comPortHandle, BUFFER=messageBuffer, $ OFFSET=offset, NMAX=n_elements(messageBuffer)-offset ; ... etc. 4) Terminate the connection in an orderly fashion if COMM_CLOSE(comPortHandle) ne 1 then $ print, 'ERROR: Orderly termination of serial port connection failed!' This is not to say that I have run any of these commands. But that is what I observe for logical coding approach and syntax based on the 'readme.txt' instructions that come with that User Contrib download. Anyhow, that is all this library does. The protocol one uses for reading and writing on the serial port is completely outside the scope of this library. You must know exactly what the format will be of the various messages you might share with the device to which you are connected. And it is likely that you must know this protocol at a very primitive level. Share with the group here what experiences you have. Good luck, James Jones
    You are not authorized to post a reply.