ComWrt on rs232

Hi people, I am facing problem in writing the data on port COM using ComWrt () .i do not know exactly where the issues is. My scenario is like whenever the com port is connected to my device, device keeping will send a message. If I ask anything between the two on my device, device must send a response based on the request. Here I can read the message of my device through ComRdByte(), if I send a msg request to the device it sends no answer, I guess that means that my device is not able to understand my message I am sending (not sure exactly). Response to the requested message can be success/error/ack msg but I get no response from my camera. I mentioned the below code to write a msg in my device #include #include int i, ch. CBC char [20], dst [20]; strcpy (src, '0346000101012A4BC0'); for (i = 0; I < strlen="" (src)="" 2;="" i++)="" {="" scan="" (src,="" "%s[i*w2]=""> [r16] %i ", I * 2, &ch);) sprintf (dst [i], "%c", ch); } ComWrt (port, dst, strlen (src) / 2); which was published in http://forums.ni.com/t5/LabWindows-CVI/add-0x-before-sending-RS232-messages/m-p/681366#M34853 an idea on where I am wrong? pls help...

Hello

Maybe this helps

int i, ch,senddata_len =0;char src[30];unsigned char dst[20];//it is nesscesary to work with binary data as unsigned, otherwise some signed/unsigned conversion happenchar dst_data[100]={0};unsigned char final_msg[100]={0};

 strcpy (src, "0346000101012A4BC0"); senddata_len = strlen(src); senddata_len-=senddata_len%2;//use only lengtht in multiple of two(if input src has bad length "034"for (i = 0; i < senddata_len ; i+=2)//process every two characters     {    //Scan (src, "%s[i*w2]>%i[r16]", i * 2, &ch);    //Scan(...)posibly good command, but i am not familiar with "Scan    //         and i think next code can be litle faster after some optimization"    //{Warning:this code not check invalid characters like "03T600"}    ch=0;    if((src[i]>='0')&&(src[i]<='9'))ch=src[i]-'0';    if((src[i]>='a')&&(src[i]<='f'))ch=src[i]-'a'+10;    if((src[i]>='A')&&(src[i]<='F'))ch=src[i]-'A'+10;    ch=ch<<4;//shift data by 4bits(the same as ch=ch*16;)    if((src[i+1]>='0')&&(src[i+1]<='9'))ch|=src[i+1]-'0';    if((src[i+1]>='a')&&(src[i+1]<='f'))ch|=src[i+1]-'a'+10;    if((src[i+1]>='A')&&(src[i+1]<='F'))ch|=src[i+1]-'A'+10;    //sprintf (&dst[i], "%c", ch);    //do not use sprintf to contencate binary data    dst[i/2]=ch;    }

    //ComWrt (port, dst, senddata_len);    //Binary data has only half size of its Ascci representation

    ComWrt (port, dst, senddata_len/2);

Tags: NI Software

Similar Questions

  • CVI 2013 can be found at #include &lt; rs232.h &gt;

    Hi, I'm a newer version of the CVI.

    my program works well in 2010,

    Initially it alos works well in 2013.but now it has the folloing error.

    the following instructions are needed in 'rs232, c', #include you want to add to the top of the file. (RS232.c) is the name of the c file).

    I click Yes, but it does not work

    the c file was already a "#inclue ".

    is there something important that I get bored?

    TKS

    Build status (rs232.prj - Debug)
    RS232.c - 8 errors
    29, 5 error: implicit declaration of function 'OpenComConfig' is not valid in C99. Make sure that you include the prototype for the function.
    31, 5 error: implicit declaration of function 'SetCTSMode' is not valid in C99. Make sure that you include the prototype for the function.
    31, 18 error: the use of the identifier not declared "LWRS_HWHANDSHAKE_OFF".
    35, 5 error: implicit declaration of function 'FlushInQ' is not valid in C99. Make sure that you include the prototype for the function.
    36, 5 error: implicit declaration of function 'FlushOutQ' is not valid in C99. Make sure that you include the prototype for the function.
    80, 20 error: implicit declaration of function 'GetInQLen' is not valid in C99. Make sure that you include the prototype for the function.
    83, 18 error: implicit declaration of function 'ComRd' is not valid in C99. Make sure that you include the prototype for the function.
    180, 14 error: implicit declaration of function 'ComWrt' is not valid in C99. Make sure that you include the prototype for the function.
    Build failed.

    Hello shayisi,

    CVI displays the error dialog box, because it has detected that some functions declared in rs232.h are used in your source file, so he offers to include the header file.

    I would like to ask you to provide some more details about your configuration, so that we can determine if there is a possible bug with CVI 2013:

    1. You are able to build the projects in the sample from the file \rs232?
    2. You have a rs232.c file that is part of your project?
    3. I understand that your project used to build without errors in CVI 2010. Is this correct?
    4. What options have you selected in the Options of language C, one of the options"Compiler Options?

    Thank you!

  • [rs232.h] ComRd (-) slow performance

    Dear users,

    I am a student in electronic engineering of approach to obtaining his diploma with a thesis on the absolute error in gsm positioning.

    I create the server application to receive an sms (at THE controls of a Siemens TC35 gsm module connected rsr232) with the RAD_ERROR_NOCONTENT information by the mobile station of the client, to develop them in order to send (using API) Google to retrieve the position with a given RAD_ERROR_NOCONTENT.

    I meet a lot of problem with ComRd which is quite slow, for example in the configuration of the connection, I need six blocks like this (one for each parameter) and total execution takes more than 15 seconds:

    **********************************************************************

    FlushInQ (ComPort);
    strcpy (writeBuf, "at clip plus 1\r"); Presentation of the identification of the appellant
    ComWrt (compote, writeBuf, strlen (writeBuf));
    Delay (0.2);
    ComRd (compote, readbuf, 10); ATTENTION! Slow down execution, even with 'ComRdTerm (compote, readBuf, 10, 0)';
    If (! findstr (readBuf, "OK", & indexBuf)) setErr = 0; check if OK responded

    **********************************************************************

    Breakpointed to the first statement and follows step by step execution, if any other statements are executed immediately, on ComRd it takes seconds. even if reading only 10 bytes. Even if I use ComRdTerm until the 0 (null).

    I can't explain why, reading only ten bytes of rs232 buffer, it takes so long. There is no time-out problem, the command is not hanging from something else!

    Can someone help me please?

    Thank you

    Luca Gallucci

    Hi Luca,

    You needn't 0.2 seconds after the call to ComWrt.

    You can directly call the ComRd, the time it takes for the GSM modem process your order and the answer is actually tolerated by the value of timeout of the port, which can be set by the SetCommTime function.

    It is possible that you are missing the answer during this wait 0.2 second.

    I highly recommend use ComRdTerm, because you may know exactly how many bytes will be after an AT command and this can cause problems because he must give the number of bytes to read into the port when you use ComRd.

    But it is guaranteed that a response of AT command will end with a CR or LF.

    Let's not how you call ComRdTerm. You must use CR or LF as end, not NULL character.

    The GSM modem will never send you a NULL character, then the function will wait until the read operation times out (because it cannot end on a NULL value), where the downturn in behavior complained.

    I hope I could make myself clear.

  • FASTRACK SUPREME - send command ATD via RS232?

    I'm working on the project, based on a FASTRACK SUPREME, that must receive the orders via a serial RS232. The

    It is:
    When I use HyperTerm the command ATDxxxxxxxxx; works very well.
    When I use the CVI RS232 library, nothing happens. Is it possible that my order stuck in

    the series buffer?
    Here is my code:

    #include
    #include
    #include
    #include
    #include
    #include
    #include

    int configurePort (void);
    int sendCommand (void);
    int port_open;
    int error;

    int main()
    {
    configurePort();
    sendCommand ();
    return 0;
    }
    int configurePort()
    {
    port_open = 0;
     
    error = OpenComConfig (4, "COM4", 115200, 0,8,1,0,-1);
    If (error)
    {
    printf("Error!\n");
    }
    If (error == 0)
    {
    port_open = 1;
    SetXMode (4, 0);
    SetCTSMode (4, 0);
    SetComTime (4, 0);
    }
     
     
    return 0;
    }
    int sendCommand)
    {
    char bufferWrite [100];
    FMT (bufferWrite, "%s", "ATD0040761768027");
    ComWrt (4, bufferWrite, 18);
    return 0;
    }
    Where is the problem? Help, please!

    Hi years,

    working with a modem can involve a few extra precaution to work with other serial devices.

    First of all, you say in Hyperterminal the modem receives orders: I remember that Hyperterminal always adds a newline at the end of each command so that you can try this first:

    ComWrt (4, 'ATD0040761768027; \r', 18);

    (BTW you can avoid passing through a string, unless you need to dynamically format during the show)

    Then, I would check in Hyperterminal if you use a form of handshake between the PC and the modem: If so, you need to satisfy the hanshaking even in your application of CVI.

    Third clue, that your modem may need an initialization to before it can satisfy a command AT; under Windows, you can configure the connection of modem to it creates a log file: create it and test it to find out the set of commands exchanged between HT and the modem.

    I guess this also addresses question of this thread : it is advisable to open only one thread per question so that everyone can add his experience and avoid the dulicating questions / answers unnecessarily.

  • Series Tecra S2 and RS232 in MS/DOS

    I have the problem that my RS232 does not work 100% in MS/DOS. In Windows XP, the RS232 interface works fine. What can I do?

    [email protected]

    Hello

    I think that you need a proper BACK driver for the RS232 port.

    At http://newsletter.toshiba-tro.de/main/index.html, you can control what material your Tecra S2 have a search a driver for it on the web!

    TOK

  • Satellite M40X-189: how to connect RGB port to port RS232?

    Hello
    as you know the satellite M40X - 189 P - M 730/XP has a port monitor RGP and doesn't have a RS232 port.
    I work with device of automatic titration requiring the RS232 port for connection!
    No idea how I can connect my laptop on this unit!

    pls help
    Thank you
    Omrankl

    Hello

    AFAIK the RS-232 port is a serial port and I don t think that it of possible to connect the RGB port to the RS232 port.
    But I found the site useful:
    http://www.Ontrak.NET/USB.htm

    You will find a description how to connect the USB port to an RS-232 port.
    You need an interface ADU.
    Click on the link.

  • PCMCIA card as a serial port RS232 on Satellite Pro 4200

    I think to use a PCMCIA card as a serial RS232 port. The program that I need to use runs under DOS and needs two serial ports. My question is that I need to run the program and the serial port to be recognized by the system. I have a satellite pro 4200 laptop PC series.

    Thank you

    Why on Earth if you want that?
    Your laptop computer with a serial port doesn't have it?

    Well for the serial ports are standard supported on Windows. In a back box that should be no problem.

    But pure back could be a problem.
    I guess you must also BACK drivers for your PCMCIA card...

  • Satellite Pro M70 - compatibility USB to RS232

    With the latest version of the BIOS and 2 RS232 totally different USB adapters, I can't get the RS232 interface to communicate with the laptop. The adapters are operating satisfactorily at least 3 other computers (1 of these loaptops was 2 door USB).
    I am running Windows XP Pro.

    Any help would be appreciated gratefully.

    Hello

    I searched the net for similar questions and a lot of people say that the converter could not work because of the SP2.
    I m not 100% sure about this, but it of possible.

    I found this page:
    http://www.Sabine.com/Sabine-professional-audio/USB-connection.htm
    On this page you will find some adapters tested and good work.

    Maybe it helps a little.

  • How to deal with the port RS232 of the SIN?

    Hello

    As my NAS does not restart because he tried to update to 6.5.1 I try to communicate with the RS232 port (four pins hidden near the kensington lock port).

    Could someone tell me the settings please? (speed/bps, bits of data, stop bits, parity, flow control)? I get the information but I can't decode it.

    Kind regards

    Roman

    Hello

    Finally I had to return my chassis to the support team. I am currently waiting for a replacement chassis to return.

    Thanks for your help guys

    Kind regards

    Roman

  • How to contact Compax3 via RS232

    "We have a driver/Compax3 servo controller and need to communicate to via RS232 and the orders of the" object "(e.g."o680.5"retrieves the current position." However, I was unable to get the controller to really transform our engine. Someone has he done that before could provide examples of code?

    LV 2009 SP 1

    Windows XP

    You should still be able to read and write objects while it is configured as a T30, but you would need to write a program of IEC which reacts to changes in your variables.  I just did a project with a positioning more comms, and it was some time ago.  My HMI would send '2O 1901.1 =' to define a position and ' $2O 6103CR "to move to the position.  Note the space, and the Czech Republic is a carriage return.  Unfortunately, Parker US doesn't have much experience with the communcations for this product, and the documentation is poor.  You can call technical support of Parker in California.  Rich Rittis would be your best bet to get answers on it.

  • I can get the data of a hygrometer using the RS232 port with the following T75.2F:H17.0% using a RS232 data logger format. I was wondering if I can collect this data for later analysis using Dasylab. Any help is appreciated.

    I can collect data from a hygrometer in a text file using the RS232 port with the following T75.2F:H17.0% format, these data are collected using a data logger software. I was wondering if I can collect this data for later analysis using Dasylab. Any help is appreciated.

    The setting below causes the error. Change for the second selection, output values of all channels.

  • USB RS232 "is connected Port" "invalid property value".

    I'm quite new to this so if all the below is not clear or needs more explanation Let me know and I will try to provide information.

    I'm trying to integrate a device in my LabView program. Of its guides, that I could find on the site OR mentioned most NI MAX goes first and then working them down. My camera is an RS232 port, so I connected via a USB converter, and I know that I'm looking at the right port (COM5) to look at the section "manage devices" on the control panel.

    All series settings are set up properly, I would say (the user manual ishere, with 17 being the party and my setup herepage). I tried to test commands, he gave me on the input/output section, but constantly came up with the error "VISA: (Hex 0xBFFF0015) timeout expired before the operation is complete." Initially, I thought I entered orders incorrectly, I find instructions in the manual that is confused, especially compared to the things other users have posted on orders ('\r' and '\n' instead of what I am told to write, but I agree that mine are not always literal characters).

    But when I went back to "Display attributes" connected "East Port" final attribute has an error with the "invalid property value" and the warning Hex 0xBFFF001Derror. Because of my inexperience with all this, I don't know where to start really trying to solve this problem, or what measures are in place, I need to do to start working properly.

    All advice is appreciated. Thank you

    The property "is connected" is only for devices of NOR so if you have another brand of converter, you would ignore the error.

  • DASYlab RS232 analysis need help

    Hi, I'm running DASYlab 13 and have implemented an RS232 input with a single channel (0) for a USB sensor which can be read normally via the COM port (port COM 13 in this case, to 115200 8 - N - 1.  I can read very well with the RS232 monitor data, I have a problem with the analysis of the data using the format in the "Measurement data Format" field of the configuration input RS232 in order to get data to display box using the meter digital, recorder, etc..

    To get the data from the probe (apart from DASYlab) I can close DASYlab (which closes the COM port) and issue a command to the sensor from the command prompt in a terminal program: B followed by the Enter key.  For example, "B\r\n" (without the quotes).

    The sensor reacts with 'AA 3 b xx xx xx xx' hex, where "AA 3 b" is a header, and x is the data.  Data format an INT32 (IEEE 754).  However, apparently so he can convert correctly with a converter to int32, France must be reversed.  I.e. If the sensor reports data as 12 34 56 78 (it is a data point made), I have to change to get what I expect as output for 78 56 34 12.  So, I'm not a Data Format to measure '2 x f' or '2 x fy' because neither one takes into account the reverse bytes format.

    How can I analyze the data, so I ignore the two-byte header (that would be x 2 or x 4?) and to reverse the order of data byte, so that the display on the digital output is correct?  I have tried all sorts of things, looked in the help files, forums, etc. and a short entry.  I am a novice user of DASYlab, so I don't know how to do the script, and I don't understand why there are several channels in each RS232 input.  I think that they allow to separate the data of a 'package' of RS232 in the individualized data points, but strings do not appear in the examples I've seen, to allow you to reorganize the data... e i. using my previous example, 12 may enter the channel 0, 34 can enter channel 1, etc., but I can't put 78 in channel 0 , 56 in channel 1, etc.  In addition, I do not understand how the data in the channels of result in the output that is displayed on the output (meter either digital, etc.).

    DASYlab1.png image shows a screenshot of my setup.  You can see the COM port monitor and the release of data by the sensor.  In this case it's 3 b 74 94 62 41 hexagonal AA.  Removing the header and reverse bytes give me 41 62 94 74 hexagonal, which is 14.16 when I convert it with http://www.h-schmidt.net/FloatConverter/IEEE754.html.  This reading (after manipulation) is correct.  However, with a '2 x f' measurement data Format parameter I get 00000000000000000000000000001110 on digital playback, which does not match anything significant.

    Your help is very appreciated.

    Thank you

    If you configure the analysis chain to assume a fixed length, then Yes, this is an expected error.

    Often, we can compensate for chains of variable length using line end or the end of data point delimiter... is the analysis of flexible length for an ASCII string. With the delimiter, we always end up at the end of the line, starting on the following.

    Always at the beginning of the anchor chain is to use a search string, if the data always starts with 3 b AA, you could try a search string to use it...

    l '\xAA \x3B '.

    You must the \x notr is hexagonal. Note also that we are not them jumping with 2 x more, but looking for them. This should keep anchored so that you get a bad data point periodically, but of legal data points are fine.

  • WHY? C program = No delays, Labview delays = &gt; &gt; Intermittent delays in the loop of RS232 serial subroutine 115200 baud. Windows 7 LV 2012

    In 30 years of developing LabVIEW I saw such a strange problem.    Maybe someone can help out me.

    Here's the problem:

    Ms 1 000 large delays occur intermittently in two instances of an executable of LabVIEW with exact system.  (SEE ATTACHED time STAMP of SCREEN CAPTURE FOR 11 and 14 COM COM where there was a > 1000 ms delay)

    • Subrotine RS232 communication loop were brought in the course of a program of 'C' that has held rock solid and did not have this same problem.
    • No record on the hard drive is in this subroutine, communication comes standard.
    • The executables are running on the same high performance server DELL 7910 communicating with satellites in Earth orbit, 24 x 7.   (RS232 115 200 Baud, Windows 7, 6 son of processor).
    • An executable uses COM 11 and the other uses COM 14.
    • The executable has the critical loop "subroutine" that injects data REVIEWS, if there is more than a 100ms delay.
    • The subroutine is not reentrant, because it is the only case used throughout the program.
    • I placed the time markers in the loop of the subroutine which tell me exactly where in the code the delay occurred.  In most but not all cases, that the delay occurs at the 'WAIT MS' or 'WAIT until the NEXT MS MULTIPLE', I tried them both, and they both have the same intermittent problem.
    • What gets me, is that the executables that are run independently of each other are logging the delay at EXACTLY the same moment.    This leads me to believe that it is a question of operating system.  Or a problem that the two executables have when competing for time to critical system resources.
    • This problem of intermittent delay occurs on other computers and on windows XP
    • The large delay occurs even when there is only one executable file running.
    • This problem is particularly bad , when the user resizes or drag the window to the executable.
    • If the system is left alone, the problem of > 1000 ms delay can happen only once or twice a day.
    • I have not yet attempted to set the priority or affinity processor running in the Task Manager
    • The executable runs as well some other non-critical time loops that perform SQL database entries, you connect the hard drive, then state machine management.

    Would like to hear from someone about it.

    Thank you

    Brad Whaley

    @ Boeing electrical engineer


  • How interface bronkhorst RS232 communication flowmeter in DIAdem DAC?

    Hello

    I am Thiyagi.I am working in WABCO INDIA Ltd. I bought Bronkhorst Flowmeter. I use the tiara DAC Professional version. I want the meter to DIAdem.Flowmeter of the interface have a RS232 communication. In my pc, I have a COM1 port. DIAdem DAC which icon I want to use to connect the flow meter.

    Hello hmongz

    You can already succeeded, but still, here's what I used to do:

    I could do this with flowmeters mass Bronkhorst and Brooks, and had a pretty good success using their method of DDE (dynamic data exchange). To do this, download their software from FlowDDE of Bronkhorst.com, start the DDE driver and he can communicate with the MFM. Once it works, insert a DDE lockk in CAD DIAdem, configure it appropriately and it should work.

    Greetings

    Michael

Maybe you are looking for

  • Satellite Pro L - Mobile phone ask driver

    I'm trying to connect my new mobile phone Samsung Galaxy S Android for my Toshiba Satellite, but the laptop won't recognise the phone and asks a driver. Can anyone help?

  • How to play Station of Pandora

    I know this sounds stupid - but how did I PLAY music from pandora. I can choose a station, add a station etc. But nothing seems to actually turn on the music. Thank you

  • A better way to generate a reference?

    I am autoindexing by a cluster control array to work with their values.  At the same time, however, I would like to update the value of the front panel control if Boolean value is selected.  Therefore, I also have automatic index through references t

  • Deleting a folder in Windows Vista Public

    Hello I have a new computer laptop, & found this public record on this matter, did not want so I deleted it... but when I restarted my PC, he was back... is there a way I could permanently delete this folder on my computer.

  • How can I stop a program c ++ running on dosbox

    How can I stop a program c ++ running on dosbox