Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. can you find the problem??

can you find the problem??

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpvisual-studioquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    August Brower
    wrote on last edited by
    #1

    I am creating a program for a children's ATM for the local kids museum, and I'm having problems sending data to the machine (over RS232). I am using a .dll supplied by the manufacturer that is used to interface the dispenser with a computer. I think the problem is in sending the hex characters to the machine. I open the port fine (according to the generated log file), but then I send and don't recieve the ACK. I'm pretty sure that it is just not sending for some reason. here is the pertinent part of the code. thanks for any help #include "stdafx.h" #include typedef struct { unsigned int uiPort; //communication port unsigned char ucDataBits; //Data bit unsigned char ucParity; //Parity bit unsigned char ucStopBits; //Stop bit unsigned long dwBaudRate; //Baud Rate HWND hwnd; //Parent window handle unsigned char ucCommandType; //command type(1: ezCDM-1000 ) }SETINFO; typedef unsigned int (*EZLINKOPEN)(SETINFO* setInfo); typedef unsigned int (*EZLINKCLOSE)(void); typedef unsigned int (*EZLINKPATH)(PCHAR pcMessage); typedef unsigned int (*EZLINKSEND)(DWORD dwCmdExcuteTime, PUCHAR pcMessage, UINT uiCmdSize); typedef unsigned int (*EZLINKRCV)(PUCHAR pcMessage, UINT *piRspSize); int _tmain(int argc, _TCHAR* argv[]) { //Loading dll------------------------------------------------------------------------------------------ HINSTANCE hdll = NULL; hdll = LoadLibrary(TEXT("ezlink")); //load the dll if (hdll == NULL) { printf("Didn't load dll\n"); //tell me if it failed } //Mapping the dll's functions-------------------------------------------------------------------------------- EZLINKOPEN ezLinkOpen; EZLINKCLOSE ezLinkClose; EZLINKPATH ezLinkPath; EZLINKSEND ezLinkSend; EZLINKRCV ezLinkRcv; ezLinkOpen = (EZLINKOPEN)GetProcAddress(hdll,"ezLinkOpen"); ezLinkClose = (EZLINKCLOSE)GetProcAddress(hdll,"ezLinkClose"); ezLinkPath = (EZLINKPATH)GetProcAddress(hdll,"ezLinkPath"); ezLinkSend = (EZLINKSEND)GetProcAddress(hdll,"ezLinkSend"); ezLinkRcv = (EZLINKRCV)GetProcAddress(hdll,"ezLinkRcv"); //handle the error if(!ezLinkOpen) //end program if dll mapping fails fails { FreeLibrary(hdll); printf("Failed to map open function!\n"); return -1; } else //otherwise, lets send some commands { unsigned int result; //Setting the log path-------------------------------------------------------------------------------------------- char message[] = "C:\\Documents and Settings\\august brower\\My Documents\\Visual Studio 2008\\Projects\\cash machine"; re

    C C 2 Replies Last reply
    0
    • A August Brower

      I am creating a program for a children's ATM for the local kids museum, and I'm having problems sending data to the machine (over RS232). I am using a .dll supplied by the manufacturer that is used to interface the dispenser with a computer. I think the problem is in sending the hex characters to the machine. I open the port fine (according to the generated log file), but then I send and don't recieve the ACK. I'm pretty sure that it is just not sending for some reason. here is the pertinent part of the code. thanks for any help #include "stdafx.h" #include typedef struct { unsigned int uiPort; //communication port unsigned char ucDataBits; //Data bit unsigned char ucParity; //Parity bit unsigned char ucStopBits; //Stop bit unsigned long dwBaudRate; //Baud Rate HWND hwnd; //Parent window handle unsigned char ucCommandType; //command type(1: ezCDM-1000 ) }SETINFO; typedef unsigned int (*EZLINKOPEN)(SETINFO* setInfo); typedef unsigned int (*EZLINKCLOSE)(void); typedef unsigned int (*EZLINKPATH)(PCHAR pcMessage); typedef unsigned int (*EZLINKSEND)(DWORD dwCmdExcuteTime, PUCHAR pcMessage, UINT uiCmdSize); typedef unsigned int (*EZLINKRCV)(PUCHAR pcMessage, UINT *piRspSize); int _tmain(int argc, _TCHAR* argv[]) { //Loading dll------------------------------------------------------------------------------------------ HINSTANCE hdll = NULL; hdll = LoadLibrary(TEXT("ezlink")); //load the dll if (hdll == NULL) { printf("Didn't load dll\n"); //tell me if it failed } //Mapping the dll's functions-------------------------------------------------------------------------------- EZLINKOPEN ezLinkOpen; EZLINKCLOSE ezLinkClose; EZLINKPATH ezLinkPath; EZLINKSEND ezLinkSend; EZLINKRCV ezLinkRcv; ezLinkOpen = (EZLINKOPEN)GetProcAddress(hdll,"ezLinkOpen"); ezLinkClose = (EZLINKCLOSE)GetProcAddress(hdll,"ezLinkClose"); ezLinkPath = (EZLINKPATH)GetProcAddress(hdll,"ezLinkPath"); ezLinkSend = (EZLINKSEND)GetProcAddress(hdll,"ezLinkSend"); ezLinkRcv = (EZLINKRCV)GetProcAddress(hdll,"ezLinkRcv"); //handle the error if(!ezLinkOpen) //end program if dll mapping fails fails { FreeLibrary(hdll); printf("Failed to map open function!\n"); return -1; } else //otherwise, lets send some commands { unsigned int result; //Setting the log path-------------------------------------------------------------------------------------------- char message[] = "C:\\Documents and Settings\\august brower\\My Documents\\Visual Studio 2008\\Projects\\cash machine"; re

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      August Brower wrote:

      result = ezLinkSend(4000,cassette;message,6);

      What is this (it looks pretty ugly, with that semicolon...)? You know, without knowing proper command format (probably you've some documentation about) we can give little help to you. BTW: please use <pre> tags (or code block button) to enclose code snippets. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      1 Reply Last reply
      0
      • A August Brower

        I am creating a program for a children's ATM for the local kids museum, and I'm having problems sending data to the machine (over RS232). I am using a .dll supplied by the manufacturer that is used to interface the dispenser with a computer. I think the problem is in sending the hex characters to the machine. I open the port fine (according to the generated log file), but then I send and don't recieve the ACK. I'm pretty sure that it is just not sending for some reason. here is the pertinent part of the code. thanks for any help #include "stdafx.h" #include typedef struct { unsigned int uiPort; //communication port unsigned char ucDataBits; //Data bit unsigned char ucParity; //Parity bit unsigned char ucStopBits; //Stop bit unsigned long dwBaudRate; //Baud Rate HWND hwnd; //Parent window handle unsigned char ucCommandType; //command type(1: ezCDM-1000 ) }SETINFO; typedef unsigned int (*EZLINKOPEN)(SETINFO* setInfo); typedef unsigned int (*EZLINKCLOSE)(void); typedef unsigned int (*EZLINKPATH)(PCHAR pcMessage); typedef unsigned int (*EZLINKSEND)(DWORD dwCmdExcuteTime, PUCHAR pcMessage, UINT uiCmdSize); typedef unsigned int (*EZLINKRCV)(PUCHAR pcMessage, UINT *piRspSize); int _tmain(int argc, _TCHAR* argv[]) { //Loading dll------------------------------------------------------------------------------------------ HINSTANCE hdll = NULL; hdll = LoadLibrary(TEXT("ezlink")); //load the dll if (hdll == NULL) { printf("Didn't load dll\n"); //tell me if it failed } //Mapping the dll's functions-------------------------------------------------------------------------------- EZLINKOPEN ezLinkOpen; EZLINKCLOSE ezLinkClose; EZLINKPATH ezLinkPath; EZLINKSEND ezLinkSend; EZLINKRCV ezLinkRcv; ezLinkOpen = (EZLINKOPEN)GetProcAddress(hdll,"ezLinkOpen"); ezLinkClose = (EZLINKCLOSE)GetProcAddress(hdll,"ezLinkClose"); ezLinkPath = (EZLINKPATH)GetProcAddress(hdll,"ezLinkPath"); ezLinkSend = (EZLINKSEND)GetProcAddress(hdll,"ezLinkSend"); ezLinkRcv = (EZLINKRCV)GetProcAddress(hdll,"ezLinkRcv"); //handle the error if(!ezLinkOpen) //end program if dll mapping fails fails { FreeLibrary(hdll); printf("Failed to map open function!\n"); return -1; } else //otherwise, lets send some commands { unsigned int result; //Setting the log path-------------------------------------------------------------------------------------------- char message[] = "C:\\Documents and Settings\\august brower\\My Documents\\Visual Studio 2008\\Projects\\cash machine"; re

        C Offline
        C Offline
        chirag_chauhan
        wrote on last edited by
        #3

        By looking at following code statements, unsigned char response[20] ; UINT *rspSize; rspSize = (PUINT)malloc(sizeof(UINT)); result = ezLinkRcv(response,rspSize); it seems like problem with rspSize, rspSize doesn't match with response memory allocatin i.e. 20. I suggest you to try out giving hard-coded 20 instead of rspSize to know exact problem and then after implement generalized logic.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups