0

I want to send data with modem rs-232 ( COM3 ) on verifone vx520. How to initialize it and how can i include it's library? How can i dial with verifone vx520?

h_modem = open(DEV_COM3 , 0);
farshid
  • 161
  • 5
  • 13
  • Is `verifone` the target modem or is it the source modem? If it is the source modem, I believe verifone has its own language called `tcl`, unless this version uses compiled c just like `rover`. If this is a target, you will need to write the code in your source using the language supported by it, or in language supported by the host PC where the source modem is connected. Is your question related to data communication? Or is it about programming in verifone `tcl`? – alvits Aug 27 '15 at 20:33
  • VeriFone used TCL in (MUCH) older models (like the Zon and Tranz terminals). Starting with the "Omni" line (like the 3200) they moved to standard C code. Thank goodness--compared to C, TCL was a real pain to deal with! – David Aug 29 '15 at 13:40

1 Answers1

2

I'm a little bit confused by your question. COM3 is the com port for the built in modem, but when we talk about rs-232, I think of port 1 on a 520 or 2 on a 570--either way, it would be for an external modem, and I'm guessing you're not talking about that... Also, your sample code is assigning a handle for the CLOCK, not the modem. Typo?

Chapter 10 of the "Verix eVo ACT Programmers Guide" is going to be your friend for modem related help. So will the "Modem Engine Function Calls" section of the same document (page 275 in my version).

I use the xmodem library for my modem functions. I'm including bits of my code I use for modem communication.

REQUEST

If you are using VMAC, then first you have to request the modem device (if you are not using VMAC, skip to the next section). A tip someone gave me once was to first turn combo mode off. This was for 37x0 terminals (Verix) and may not be relevant anymore, but I still do it:

set_combo_mode(0)

I then send a custom event that is defined in my .rck file as follows:

(HIGH,  MODEM_REQUEST_EVENT,    MODEM_EVENT,    {(COMM_3)})

If you are using VMAC, you should already be familiar with the fact that this table is defined as "Priority, input event, output event, devices". Further explanation is beyond the scope of this answer.

OPEN

Next, you'll need to open the modem and get the handle:

hModem = open(DEV_COM3, 0);

Be sure to verify that hModem > 0 and deal with cases where it is not.

INITIALIZE

First you have to initialize the terminal <-> modem interface:

struct Opn_Blk Com3ob;

Com3ob.rate = Rt_115200;
Com3ob.format = Fmt_A8N1; //another common rate is Fmt_A7E1
Com3ob.protocol = P_char_mode;
Com3ob.parameter = 0;

set_opn_blk(hModem, &Com3ob);

Note: communication rate can be faster than the modem connection because the modem can communicate with the host system at one speed and also talk to the terminal at another. Note that it would be wise to always make the terminal to modem speed greater than the modem to host speed.

Then you may also have to send an initialization string to the modem to set communication options between the modem and the server you are dialing into:

write(hModem, "+++", 3); // put the modem into "Command mode"
write(hModem, ATString, ATStringLength); // be sure ATString ends with '\r'
//read(hModem, buffer, readLength) --> process the response. 
// How you do that will depend on if echo and or verbose is on

DIAL

int result = xmdm_get_line_dial(hModem, dial_string, &iWrite, hClock, 30);

Notes from documentation:

dial_string must be a null-terminated string containing valid dialing information (see Table 18), and must be large enough to accommodate the four extra command characters used by this function. The longest Hayes command that can be sent is 40 bytes.

When xmdm_get_line_dial() returns, iwrite contains the number of bytes written to the modem command buffer, and dial_string contains the complete dial command string whose string length should be equal to iwrite for a successful dial.

Note that "30" above is the timeout in seconds. If you pass in 0, it will not time out.

Check result to make sure you connected (some wise-guy at Hayes decided to split these connect values up):

if( result == CONNECT ||
    result == CONNECT_300 ||
    result== CONNECT_1200 ||
    (result >= CONNECT_600 && result <= CONNECT_115200) )

SEND & RECEIVE DATA

int totalBytesRead = xmdm_receive_data(hModem, buffer, 1, 1, 1000);

read from [hMmodem], into [buffer], ([1]-ignored), upto [1] char(s), timeout after [1000] "centiseconds" (100ths of a second, i.e. 10 seconds). Note that totalBytesRead will be negative on error. Check the documentation for the various possible return values.

int totalBytesSent = xmdm_send_data (hModem, buffer, i, 300);

send [i] bytes from [buffer] to [hmodem], timeout after [300] "centiseconds" (3 seconds). Note that totalBytesSent will be negative on error. Check the documentation for the various possible return values.

CLOSE

close(hModem);

RETURN TO VMAC

EESL_send_event("DEVMAN", COMM_3_RELEASED_EVENT, (unsigned char*) 0, 0);
David
  • 4,665
  • 4
  • 34
  • 60
  • where can we write our destination number (phone number)? by which command can change the number ? – farshid Aug 31 '15 at 13:39
  • In the *DIAL* example above, `xmdm_get_line_dial(hModem, dial_string, &iWrite, hClock, 30);`, `dial_string` is the phone number. It may also contain things like a dialing prefex to get an outside line (like 9) and/or a comma (,) to indicate a pause, etc. – David Aug 31 '15 at 16:57