LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Datasocket problem, Error: Unrecognized data format while trying to read a simple Text file via http

Hello. I want to call a webpage via HTTP and read the given answer. I'm using the Datasocket/Reader Example for this, and it works fine with most webpages I've testet, but unforunatley not with the one, I really need. I always get the "Error: Unrecognized data format" exception and the page wasn't read. Btw: the page only contains a result number without any html-tags, like "201". Does anyone know, what's going wrong or a alternative to call my webpage? With best regards der Ben
0 Kudos
Message 1 of 6
(5,207 Views)
Ok, let's try it another way. The error text form datasocket is "Unrecognized data format". Might it be possible to SET the used data format by the programm? Just like telling the datasocket "hey man, just think that are ascii-characters, and go on..."...
0 Kudos
Message 2 of 6
(5,190 Views)
Hi,
 
in Datasocket Read you have the type of your datas. In the Url you have the files type you get access. I suppose that your special html side don´t have the right source code you need. you can test it with save the *.html side and then get access to the offline side. Please attache hear your code with url to html file. Here´s a screenshot from ds reader.vi with the data type connection in datasocket read.vi
 
Best Regards
 
AE Munich (Germany)
 
 
0 Kudos
Message 3 of 6
(5,179 Views)
Here are informations for read different file types (Text, html, Wave-File...) - each file must be valid (e.g. right header for html source code...)
 
  • General:
    In general, DataSocket is an easy-to-use, high-performance programming tool that is designed specifically for sharing and publishing live data in measurement and automation applications between different applications and between machines across the Internet.

    Although a variety of different technologies exist today to share data between applications, including TCP/IP, most of these tools are not targeted for live data transfer to multiple clients. With TCP/IP, you have to convert your data into an unstructured stream of bytes in the broadcasting application and then parse the stream of bytes back into its original format in subscribing applications. DataSocket, however, simplifies live data transfer. DS (based on TCP/IP) only supported NI-proprietary protocol. We called it DataSocket. It is based on TCP/IP and it's using 3015 port (both 3015 TCP and 3015 UDP ports are registered for nati-dstp. See link below.

  • Read & Write:
    To begin, Datasocket can read more data types than it can actually write. As we discussed, it can read 4 types: text, tab delimited text, .wav sound files, and DSD, or datasocket data. Now, it can only write text or DSD. So, as of now, you MUST add [text] at the end of the URL if you intend to read a text file. For more information on DSD, see below. To read a text file from an ftp site, again you must add [text] at the end of the URL otherwise, you’ll get a Runtime error 13.

    There also exists a DSL file, you’d want to use a DSL file if you often change the URL to the DataSocket Server. For example, if the DataSocket Server is unavailable and you want to move the server to another location, you can change the URL in the DSL file instead of changing the URL in every application that reads data from the server. Even though you moved the server, the reading process is transparent to users. The readers connect to the DSL file and the file redirects the reader to the URL contained in the file. A DataSocket Link (DSL) file is similar to an .ini file. DSL files contain the URL of the DataSocket Server with a named tag for the data appended, such as dstp://127.0.0.1/wave. When using DSL you must define the data type of the data to read. You might want to place the DSL file on a network drive where all readers can access it. You also can place the DSL file on a web server that exports the DSL file to users beyond your internal network. For example, use the web server approach if readers are on UNIX machines and you do not want to configure SAMBA for drive sharing.

    Creating a DSL File:
    Use any text editor to create and open a new text document. Type the following, where 127.0.0.1 is the URL of the server and wave is the named tag for the data:
    [InternetShortcut]
    URL=dstp://127.0.0.1/wave
    Save and close the file and change the file extension from .txt to .dsl.

  • Protocol Types:
    You can use the following protocols when you publish or subscribe to data using DataSocket:

    • DataSocket Transport Protocol (dstp) The native protocol for DataSocket connections. When you use this protocol, the VI communicates with the DataSocket server. You must provide a named tag for the data, which is appended to the URL. The DataSocket connection uses the named tag to address a particular data item on a DataSocket server. To use this protocol, you must run a DataSocket server.

    • Windows OLE for Process Control (opc) Designed specifically for sharing real-time production data, such as data generated by industrial automation operations. To use this protocol, you must run an OPC server.

    • Windows logos An internal National Instruments technology for transmitting data between the network and your local computer.

    • File Transfer Protocol (ftp): You can use this protocol to specify a file from which to read data.

    • file: You can use this protocol to provide a link to a local or network file that contains data.


    The following shows examples of each protocol URL.

    URL Example:

    dstp dstp://servername.com/numericdata, where numericdata is the named tag

    opc opc:\National Instruments.OPCTest\item1opc:\\machine\National Instruments.OPCModbus\Modbus Demo

    Box.4:0opc:\\machine\ National Instruments.OPCModbus\Modbus Demo Box.4:0?updaterate=100&deadband=0.7

    logos logos://computer_name/process/data_item_name

    ftp ftp://ftp.natinst.com/datasocket/ping.wav

    file file:ping.wavfile:c:\mydata\ping.wavfile:\\machine\mydata\ping.wav

    Use the dstp, opc, and logos URLs to share live data because these protocols can update remote and local controls and indicators.

    Use the ftp and file URLs to read data from files because these protocols cannot update remote and local controls and indicators.

    Refer to the DataSocket Examples for examples of using DataSocket connections.

    DataSocket (implementation) can use any of these protocols - It'll use the one that you tell it to use by the header of the URL (dstp: or opc: logos: etc). All these protocols are isolated and don't depend on each other. In other words DataSocket (implementation) has embedded clients for all these protocols and will use the specified by the URL.

  • Summary, Visual Basic Specifically:
    Beyond that there is a complete compilation for Datasocket in Visual Basic that is a great starting point. Please take a look: http://zone.ni.com/devzone/devzone.nsf/webcategories/7CDA3E51FEFC4AA2862568B80071A1E2?opendocument
  • Message 4 of 6
    (5,178 Views)
    Hello Johann.Wagner. I like to say: Thank you! Your advice to set a simple [text] after my URL has cleared my problem. If you'd like to know: I am calling a .CGI file via HTTP that answers with a simple text like "234" - no formatings or anything else.. With best Regards Ben
    0 Kudos
    Message 5 of 6
    (5,173 Views)

    Hello,

     

    Is it possible to read data from DSTP server using TCP vi's?

     

    The problem is that Labview PDA module is not supporting DSTP protocol but only TCP!

     

    Thank you!

    0 Kudos
    Message 6 of 6
    (4,792 Views)