Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can't write plc variable qt
Forum Updated to NodeBB v4.3 + New Features

Can't write plc variable qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 325 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.
  • V Offline
    V Offline
    V0rtex
    wrote on last edited by
    #1
    char  szVar[] = {"MAIN.PLCVar"};
    AdsSyncReadWriteReq(pAddr, ADSIGRP_SYM_HNDBYNAME, 0x0, sizeof(lHdlVar), &lHdlVar, sizeof(szVar), szVar);
        //AdsSyncReadReq( pAddr, ADSIGRP_SYM_VALBYHND, lHdlVar, sizeof(nData), &nData );
        AdsSyncWriteReq(pAddr, ADSIGRP_SYM_VALBYHND, lHdlVar, sizeof(nData), &nData);
        AdsSyncWriteReq(pAddr, ADSIGRP_SYM_RELEASEHND, 0, sizeof(lHdlVar), &lHdlVar);
    qDebug()<<nData;
    

    when i do that this works fine but i want to make a function that write plc variable in function then set value what i want.

    __declspec( dllexport )
    long __stdcall AdsSyncReadWriteReq( AmsAddr* pAddr,					// Ams address of ADS server
    							unsigned long indexGroup,			//	index group in ADS server interface
    							unsigned long indexOffset,			// index offset in ADS server interface
    							unsigned long cbReadLength,		// count of bytes to read
    							void* pReadData,						// pointer to the client buffer
    							unsigned long cbWriteLength, 		// count of bytes to write
    							void* pWriteData						// pointer to the client buffer
    							);
    

    this is function

    and when i want to do that this error is happening

    ads.cpp:35:5: error: no matching function for call to 'AdsSyncReadWriteReq'
    TcAdsAPI.h:67:16: note: candidate function not viable: no known conversion from 'char' to 'void *' for 7th argument; take the address of the argument with &
    
    void ADS::ChangeValue(char varName)
    {
        
        nData=80.1;
        AdsSyncReadWriteReq(pAddr, ADSIGRP_SYM_HNDBYNAME, 0x0, sizeof(lHdlVar), &lHdlVar, sizeof(varName), varName);
        //AdsSyncReadReq( pAddr, ADSIGRP_SYM_VALBYHND, lHdlVar, sizeof(nData), &nData );
        AdsSyncWriteReq(pAddr, ADSIGRP_SYM_VALBYHND, lHdlVar, sizeof(nData), &nData);
        AdsSyncWriteReq(pAddr, ADSIGRP_SYM_RELEASEHND, 0, sizeof(lHdlVar), &lHdlVar);
        qDebug()<<nData;
    }
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      And where's the relation to Qt? You call a simple C function but don't pass the correct type for the 7th argument. Fix it.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • V Offline
        V Offline
        V0rtex
        wrote on last edited by
        #3

        I know but may be you can help i tried and i cant

        jsulmJ 1 Reply Last reply
        0
        • V V0rtex

          I know but may be you can help i tried and i cant

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @V0rtex What did you try to solve "no known conversion from 'char' to 'void *' for 7th argument"?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          V 1 Reply Last reply
          0
          • jsulmJ jsulm

            @V0rtex What did you try to solve "no known conversion from 'char' to 'void *' for 7th argument"?

            V Offline
            V Offline
            V0rtex
            wrote on last edited by
            #5

            @jsulm yes i tried but i cant still. i didn't understand

            SGaistS 1 Reply Last reply
            0
            • V V0rtex

              @jsulm yes i tried but i cant still. i didn't understand

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              @V0rtex said in Can't write plc variable qt:

              @jsulm yes i tried but i cant still. i didn't understand

              The question was: can you please explain what you tried that did not work ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved