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
C

cahit23

@cahit23
About
Posts
8
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How split up a double value into 8 sets of uint8
    C cahit23

    DavidCrow wrote:

    Do you not think it pertinent to include the line number of the code this error refers to? We're not mind readers.

    Oh sorry, pointed lines are : real_T d; and ** real_T is the representation of double in this format, even if i write there 'double' appears again as error ** num.d = *uPtrs[0]; Thank you for your consideration! Cahit

    C / C++ / MFC help

  • How split up a double value into 8 sets of uint8
    C cahit23

    Hi all, i am working on a simulink model (graphical block programming) and in a block i am supposed to write a user defined function (S-Function) which takes a double value and outputs 8 uint8 values. It has some simulink related commands but basically C Code. Since i have an error message, i would like to share it with you all to find a way out. #define S_FUNCTION_NAME double2integer #define S_FUNCTION_LEVEL 2 #include "simstruc.h" typedef union { uint8_T uvalue[8]; real_T d; //real_T is double } UnionNum; static void mdlInitializeSizes(SimStruct *S) { ssSetNumSFcnParams(S, 0); if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) { return; /* Parameter mismatch will be reported by Simulink */ } if (!ssSetNumInputPorts(S, 1)) return; ssSetInputPortWidth(S, 0, 1); ssSetInputPortDataType(S, 0, SS_DOUBLE); ssSetInputPortDirectFeedThrough(S, 0, 1); if (!ssSetNumOutputPorts(S,1)) return; ssSetOutputPortWidth(S, 0, 8); ssSetOutputPortDataType(S, 0, SS_UINT8); ssSetNumSampleTimes(S, 1); ssSetOptions(S,0); } static void mdlOutputs(SimStruct *S, int_T tid) { int_T i; int_T width = ssGetOutputPortWidth(S,0); InputPtrsType uPtrs = ssGetInputPortSignalPtrs(S,0); uint8_T *y = (uint8_T *)ssGetOutputPortSignal(S,0); UnionNum num; num.d = *uPtrs[0] ; for(i=0; i

    C / C++ / MFC help

  • reading and sending errors to serial port [modified]
    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 / C++ / MFC c++ help collaboration question

  • Linking Error /outportb
    C cahit23

    Hello, I received an error message when i tried to send serial port the datas with outportb. %Starting with dos.h library ... int port=0x378; outportb(int port, unsigned int); ... ... for ( i=0 ; i<8 ; i++) { outportb(port,member.u8value[i]); } ... Error Message ==> [Linker Error] Unresolved external '_outportb' referenced from H:\INTERFACE\INTERFACE.OBJ (Interface is the file in which all datas are saved) What could be the problem? Thanks for your tricks in advance. Regards, Cahit

    C / C++ / MFC help question

  • Linking Error / outportb [modified]
    C cahit23

    Hello everyone, Thank you for your suggestions in my previous message.It's working.As next step, i want to send my uint8 values here to serial port.For that i added two lines into my code (bold) but i receive this error, [Linker Error] Unresolved external '_outportb' referenced from H:\INTERFACE\INTERFACE.OBJ (Interface is the name of my file in which i saved my code and files) I didnt get the cause of problem,what's wrong?. If anyone has an idea, would be pleased! #include #include #include #include // system() int transmit (double x); int i; system(); outportb(int port, unsigned int); int transmit (double x) { union ifas { double d; unsigned char u8value[8]; }; union ifas member; member.d = x; printf("\nmember.d=%d\n",member.d); for ( i=0 ; i<8 ; i++) { printf("\nmember.u8value[%d]=%f\n",i,member.u8value[i]); outportb(port,member.u8value[i]); } return 0; } int main(int argc, char* argv[]) //Console { double var; scanf("%lf",&var); transmit(var); system("pause"); return 0; } Regards, Cahit -- modified at 11:37 Thursday 17th August, 2006

    C / C++ / MFC help question

  • How to send double value as 8 uint8 values?
    C cahit23

    Hi all, I am currently working on Serial Interface between a control box and PC and want to send/receive double values from Pc to the box as 8 uint8 values since the box only accepts in uint8 form. For that i thought as follows : to get that double value (64 bits) in binary form and get the last 8 bits with &(and) operator and shifting bits to right till all bits are finished,namely : double var; char var2send[8]; % in array var2send[0]= var & 0x00000000000000ff % last 8 bits with & operator var>>8; %shifting bits var2send[1]= var & 0x00000000000000ff var>>8; . . % and sending this array as output . But in this code, i received an error that says i cant use double with & operators so that must be converted 64 bit long form.Besides, cast function rounds my double value to the nearest integer even if i type number like 23.34353 with precision. How can i manage to do this?? or anyone has better way or suggestion? I hope i could clearly explain my problem. I would be very pleased if you could help me! Thanks a lot! Cahit

    C / C++ / MFC help question data-structures tutorial

  • How to send double value as 8 uint8 values??
    C cahit23

    oh sorry, i deliver my message in visual c++ forum then!

    Managed C++/CLI help question data-structures tutorial

  • How to send double value as 8 uint8 values??
    C cahit23

    Hi all, I am currently working on Serial Interface between a control box and PC and want to send/receive double values from Pc to the box as 8 uint8 values since the box only accepts in uint8 form. For that i thought as follows : to get that double value (64 bits) in binary form and get the last 8 bits with &(and) operator and shifting bits to right till all bits are finished,namely : double var; char var2send[8]; % in array var2send[0]= var & 0x00000000000000ff % last 8 bits with & operator var>>8; %shifting bits var2send[1]= var & 0x00000000000000ff var>>8; . . % and sending this array as output . But in this code, i received an error that says i cant use double with & operators so that must be converted 64 bit long form!! How can i manage to do this?? or anyone has better way or suggestion? I hope i could clearly explain my problem. I would be very pleased if you could help me! Thanks a lot! Cahit

    Managed C++/CLI help question data-structures tutorial
  • Login

  • Don't have an account? Register

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