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. reading and sending errors to serial port [modified]

reading and sending errors to serial port [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpcollaborationquestion
2 Posts 2 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.
  • C Offline
    C Offline
    cahit23
    wrote on last edited by
    #1

    Hello, I am trying to send serial port a double value as 8 sets of uint8 by means of union and receiving in the same manner. For that, im calling read and write functions from an external '.cpp'file through class-object implementation as you see in my code.I use that implementation seperately in transmit and receive functions. int transmit (double x) { union ifas { double d; unsigned char u8value[8]; //uint8 }; union ifas member; CSyncSerialComm *ObjectCSyncSerialComm; //Object in class from ext.file ObjectCSyncSerialComm = new CSyncSerialComm("0x3F8"); member.d = x; printf("\nmember.d=%f\n",member.d); ObjectCSyncSerialComm.WriteFile(m_hSerialComm, member.u8value, 8, &dwNumberOfBytesWritten, NULL); delete ObjectCSyncSerialComm ; return (int) member.u8value; } double receive(unsigned char) { union aachen { double c; unsigned char u8value[8]; }; union aachen team; CSyncSerialComm *ObjectCSyncSerialComm; ObjectCSyncSerialComm = new CSyncSerialComm("0x3F8"); ObjectCSyncSerialComm.ReadFile(m_hSerialComm, &szBuf, 10, &dwIncommingReadSize, NULL); delete ObjectCSyncSerialComm ; return (double)team.c ; } int main(int argc, char* argv[]) { double var; unsigned char z; scanf("%lf",&var); transmit(var); receive(z); return 0; } What i want to ask you is, in writing and reading commands i'm receiving syntax errors. If I type both in reading and writing (bold lines), ObjectCSyncSerialComm.ReadFile(m_hSerialComm, &szBuf, 10, &dwIncommingReadSize, NULL); Error==> On the left side of the structure . or .* is required If I type as follows, ObjectCSyncSerialComm.*ReadFile(m_hSerialComm, &szBuf, 10, &dwIncommingReadSize, NULL); Error==> Invalid pointer used. By the way, im using C++ Builder 6.0 Compiler. What could be the problem? Any other problem can cause this? I could not find any solution. Any comment and/or suggestion will be appreciated.Thank you. Regards, Cahit -- modified at 12:01 Friday 18th August, 2006

    C 1 Reply Last reply
    0
    • C cahit23

      Hello, I am trying to send serial port a double value as 8 sets of uint8 by means of union and receiving in the same manner. For that, im calling read and write functions from an external '.cpp'file through class-object implementation as you see in my code.I use that implementation seperately in transmit and receive functions. int transmit (double x) { union ifas { double d; unsigned char u8value[8]; //uint8 }; union ifas member; CSyncSerialComm *ObjectCSyncSerialComm; //Object in class from ext.file ObjectCSyncSerialComm = new CSyncSerialComm("0x3F8"); member.d = x; printf("\nmember.d=%f\n",member.d); ObjectCSyncSerialComm.WriteFile(m_hSerialComm, member.u8value, 8, &dwNumberOfBytesWritten, NULL); delete ObjectCSyncSerialComm ; return (int) member.u8value; } double receive(unsigned char) { union aachen { double c; unsigned char u8value[8]; }; union aachen team; CSyncSerialComm *ObjectCSyncSerialComm; ObjectCSyncSerialComm = new CSyncSerialComm("0x3F8"); ObjectCSyncSerialComm.ReadFile(m_hSerialComm, &szBuf, 10, &dwIncommingReadSize, NULL); delete ObjectCSyncSerialComm ; return (double)team.c ; } int main(int argc, char* argv[]) { double var; unsigned char z; scanf("%lf",&var); transmit(var); receive(z); return 0; } What i want to ask you is, in writing and reading commands i'm receiving syntax errors. If I type both in reading and writing (bold lines), ObjectCSyncSerialComm.ReadFile(m_hSerialComm, &szBuf, 10, &dwIncommingReadSize, NULL); Error==> On the left side of the structure . or .* is required If I type as follows, ObjectCSyncSerialComm.*ReadFile(m_hSerialComm, &szBuf, 10, &dwIncommingReadSize, NULL); Error==> Invalid pointer used. By the way, im using C++ Builder 6.0 Compiler. What could be the problem? Any other problem can cause this? I could not find any solution. Any comment and/or suggestion will be appreciated.Thank you. Regards, Cahit -- modified at 12:01 Friday 18th August, 2006

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

      ObjectCSyncSerialComm->ReadFile

      cje

      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