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 Update on Monday, May 27th 2025

Can't write plc variable qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 321 Views
  • 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 11 Jul 2021, 15:07 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
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 11 Jul 2021, 15:15 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 11 Jul 2021, 15:49 last edited by
        #3

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

        J 1 Reply Last reply 12 Jul 2021, 06:06
        0
        • V V0rtex
          11 Jul 2021, 15:49

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

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 12 Jul 2021, 06:06 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 12 Jul 2021, 14:55
          0
          • J jsulm
            12 Jul 2021, 06:06

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

            V Offline
            V Offline
            V0rtex
            wrote on 12 Jul 2021, 14:55 last edited by
            #5

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

            S 1 Reply Last reply 12 Jul 2021, 19:00
            0
            • V V0rtex
              12 Jul 2021, 14:55

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

              S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 12 Jul 2021, 19:00 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

              1/6

              11 Jul 2021, 15:07

              • Login

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