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);
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);
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);