|
if i just use broadcast to send data , and i didn't use socket to connect ,can someone teach me how can i to handle the data of response in the broadcast plz and thank u.
|
|
|
|
|
Since you dont make socket connection with individual pc you cant have serv/responce kinda architecture... I belive you are using DGRAM/UDP Sock. In this case you should consider each communication as independent from anyother communication....
Onething you can do is have Packet type for each UDP transer. so that you know that this packet is in response to some packet you had send earlier....
I hope I helped you in someway.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Yes, you are right.
But i still no idea how to get the packet...
I know i should receive the packet in one selected port,but i don't know how to do it...
can anyone help me plz?
|
|
|
|
|
Click Click[^]
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
there are many kinds of broadcast, for example 192.168.0.255 is a broadcast for the net 192.168.0.x.
the biggest possible broadcast is 255.255.255.255, every computer in the net will receive and parse this. so the way is to bind the udp sockets on addresses like INADDR_ANY.
Don't try it, just do it!
|
|
|
|
|
this is my code
WSADATA data;
WORD version;
SOCKET socket_sd;
struct sockaddr_in s_to,s_sourse;
version = (MAKEWORD(2,2));
WSAStartup(version,&data);
s_sourse.sin_family = AF_INET;
s_sourse.sin_port = htons(64513);
s_sourse.sin_addr.s_addr = htonl(INADDR_ANY);
s_to.sin_family = AF_INET;
s_to.sin_port = htons(64515);
s_to.sin_addr.s_addr = htonl(INADDR_ANY);
socket_sd = socket(AF_INET, SOCK_DGRAM, 0);
bind(socket_sd, (struct sockaddr far *)&s_sourse, sizeof(s_sourse));
sendto( socket_sd, (char *)&sendbuf,sizeof(sendbuf), 0, (struct sockaddr far *)&s_to, sizeof(s_to) );
can anyone tell me why i can't send the broadcast plz???
|
|
|
|
|
I'm using CWebBrowser2 in a dialog and would like to prevent the user from being able to go back, forward and change the font size by clicking Alt-LeftArrow, Alt-RightArrow and using the mousewheel. Does anyone know how to do this? Thanks,
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi,
when I compile my program all are ok.
And when I execute my program an error appear :
dlgdata.cpp error in line 43
I have 2 PCs with VC++ and I have the same problem when I executed the program.
Best Regards
youssef
|
|
|
|
|
You're hitting an ASSERT because you're trying to bind via DDX to a nonexistent control. (Shameless self-promotion) this article[^] will help you understand how to understand and debug these kinds of problems.
Rob Manderson
Colin Davies wrote: I'm sure Americans could use more of it, and thus reduce the world supply faster. This of course would be good, because the faster we run out globally, the less chance of pollution there will be. (Talking about the price of petrol) The Soapbox, March 5 2004
|
|
|
|
|
You are right .
|
|
|
|
|
Hi. Currently I have a Visual C+ program that communicates with a GPS device through a serial-to-USB interface. Analysis of the GPS information leads to a set of control signals being sent to a Motorola HC12 Microcontroller. I was wondering if anyone had any ideas on how this process could take place. Basically the micro controls acceleration and steering for an autonomous vehicle I am working on. From the micro, 5 volts control an analog switch varying +/- 12 volts to a steering motor and alos from the micro a bit signal that sets the correct wiper setting in the digital potentiometer. I need a way to send a signal from the Windows XP laptop I am using to the microcontroller through a serial port. I am using the MarshallSoft GPS DLL to manipulate the USB port that the GPS information comes into. Since I have a serial-to-usb conversion acting on COM4, how do I take control of Com1 lets say and send a particular bit pattern to the micro?????Any help would greatly be appreciated.
|
|
|
|
|
Got me. But if I was going to try to do that, I'd look at how the free software works from parallax.com, interesting stuff. Basic stamps and PLC's and such.
Best I can do.
Gyrogearloose
|
|
|
|
|
If you're asking how to send data over a serial port, you can open "COM1" as a file using CreateFile() and send characters using WriteFile() . If you're asking something else, you'll have to be a lot clearer.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ok let me lay it out for everyone so they have a cleaer picture.
Free to use
This is the c file I am using.
//RMC Message Parser
// COMPILE: From the command line:
//
// nmake -f gprmc._m_
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <iostream.h>
#include <fstream.h>
#include "mgc.h"
#include "keycode.h"
char DataBuffer[256];
int Port;
double latitude;
double longitude;
double currentlatitude;
double currentlongitude;
/* For error detection */
int ShowMGC32Error(int Code)
{
static char ErrBuffer[128];
mgcErrorText(Code, (char *)ErrBuffer);
printf("%s\n", ErrBuffer);
return Code;
}
/*** main ***/
void main(int argc, char *argv[])
{
int Code;
/* process args */
if(argc!=2)
{
printf("Usage: GPRMC <port>\n");
return;
}
Code = mgcAttach(MGC_KEY_CODE); //checks for proper identification
if(Code<0)
{
printf("Error %d: Cannot attach MGC32.DLL, check key code\n", Code);
return;
}
Port = atoi(argv[1]) - 1; //converts string into an integer
Code = mgcOpen(Port); //opens com
if(Code<0)
{
ShowMGC32Error(Code);
exit(1);
}
printf("GPRMC Test Program\n");
printf("MGC Version %1d.%1d.%1d\n",
mgcGetInteger(MGC_GET_VERSION_DIGIT1),
mgcGetInteger(MGC_GET_VERSION_DIGIT2),
mgcGetInteger(MGC_GET_VERSION_DIGIT3));
// specify which sentence (RMC)
Code = mgcSetInteger(MGC_SET_SENTENCE_TYPE, MGC_SENTENCE_GPRMC);
if(Code<0)
{
ShowMGC32Error(Code);
exit(1);
}
printf("Enter destination latitude: \n");
cin>>latitude;
printf("Enter destination longitude:\n");
cin>>longitude;
printf("Alex Czeto GPS RMC Message Parser Test Version \n");
printf("Date Time V Speed Course Latitude Longitude \n");
printf("==== ==== = ===== ====== ======== ========= \n");
while(1)
{// was any key pressed ?
if(kbhit()) break;
// lock data buffer
mgcLockData(1);
// get date
Code = mgcGetData(GPRMC_DATE,(LPSTR)DataBuffer);
if(Code<0) ShowMGC32Error(Code);
if(Code==1)
{// reference count = 1 (1st time seen this data)
if(Code>0) printf("%5s ", DataBuffer);
// get timestamp
Code = mgcGetData(GPRMC_UTC_TIME,(LPSTR)DataBuffer);
if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%5s ", DataBuffer);
// get validity
Code = mgcGetData(GPRMC_VALIDITY,(LPSTR)DataBuffer);
if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%s ", DataBuffer);
// get speed
Code = mgcGetData(GPRMC_SPEED,(LPSTR)DataBuffer);
if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%5s ", DataBuffer);
// get course
Code = mgcGetData(GPRMC_COURSE,(LPSTR)DataBuffer);
if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%5s ", DataBuffer);
// get Latitude
Code = mgcGetData(GPRMC_LATITUDE,(LPSTR)DataBuffer);
currentlatitude=Code;
if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%8s ", DataBuffer);
// get North/South
Code = mgcGetData(GPRMC_NORTH_SOUTH,(LPSTR)DataBuffer);
if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%s ", DataBuffer);
// get Longitude
Code = mgcGetData(GPRMC_LONGITUDE,(LPSTR)DataBuffer);
if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%8s ", DataBuffer);
// get East/West
Code = mgcGetData(GPRMC_EAST_WEST,(LPSTR)DataBuffer);
if(Code<0) ShowMGC32Error(Code);
if(Code>0) printf("%s\n", DataBuffer);
}
// unlock data buffer
mgcLockData(0);
Sleep(200);
}
mgcClose();
} /* end main */
and this is the potentiometer code that is running on the Motorola HC12 microcontroller
* Equate registers addresses
*-------------------------------------------------
copctl equ $0016 ;COP Control Register
mode equ $000b ;mode register
reset equ $fffe ;reset
sp0cr1 equ $00d0 ;spi control register 1
sp0cr2 equ $00d1 ;spi control register 2
sp0br equ $00d2 ;spi boud rate register
sp0sr equ $00d3 ;spi status register
sp0dr equ $00d5 ;spi data register
ports equ $00d6 ;port s data register
ddrs equ $00d7 ;data direction register for port s
purds equ $00db ;pull-up and reduced drive for port s
cs equ $0004 ;chip select (ps2)
*-------------------------------------------------
* Digital POT command and data bytes
*-------------------------------------------------
command equ $13 ;command byte for the digital pot
data equ $50 ;digital value to set the wiper position
*-------------------------------------------------
* Set register values for SPI
*-------------------------------------------------
org $8000 ;program the Flash EEProm
start ldaa #$19 ;special single chip mode
staa mode
ldaa #$00 ;turn off watchdog
staa copctl
ldaa #$5e
staa sp0cr1 ;set control register 1
clra
staa sp0cr2 ;set control register 2
staa sp0br ;set boud rate
staa purds ;set pull-up and reduced drive for ports
ldaa #$ff
staa ddrs ; set data direction register for ports
*-------------------------------------------------
* Program the POT
*-------------------------------------------------
bclr ports,cs ;select digital pot
ldaa #command ;load the command byte
staa sp0dr ;store command byte to the SPI data register
bsr transmit ;program the command byte
ldaa #data ;load the data byte
staa sp0dr
bsr transmit ;program the data byte
bset ports,cs ;deselect digital pot
swi ;software interrupt
*-------------------------------------------------
* Transmit data thru SPI
*-------------------------------------------------
transmit brset sp0sr,$80,done ;wait until the end of transmission
bra transmit
done ldaa sp0sr ;clear SPIF (SPI interrupt request)
ldaa sp0dr ;
rts ;return from subroutine
*-------------------------------------------------
* Set reset vector
*-------------------------------------------------
org reset ;set reset vector
dw start ;upon reset goto 'start'
*=================================================
Basically I need to send a 8bit code from the GPS program to the microcontroller to the data register value in memory. This digital value sets the wiper position on the potentiometer which the microcontroller is wired to.
When the GPS program determines a change in speed is neccesary, the signal will be sent.
|
|
|
|
|
|
Recently I've installed Windows XP on my PC, and now I'm trying to upgrade some of my progs to have the "XP looks". I searched MSDN for the solution, found it, used it, and everything was all right, except that the buttons with bitmaps instead of text didn't change the style. They are still displayed as an ordinary semi-3D rectangles, and frankly I don't know what to do.
If anyone knows a solution to my little problem, I'd be very greatful.
Paksas
|
|
|
|
|
You need to draw your bitmaps/icons to match the XP look and feel; otherwise, you've just got the old '3-D' look. The 'theme' API stuff doesn't take care of drawing your bitmaps with the anti-aliasing and the special lighting. This article[^] on MSDN talks a little bit about how to create icons. They mention this link[^] in the article.
Software Zen: delete this;
|
|
|
|
|
I also found this article[^] that explains the process they expect you to use when creating icons.
Software Zen: delete this;
|
|
|
|
|
If I have a button that creates a modal dialog (dlg.DoModal ()) should that create the dialog box on the fly using the dialog resource file or does it actually maintain it somewhere in memory and just show it again (if it's not the first call)? For example if I open the dialog, disable some controls, closed the dialog, then open it again should those controls still be disabled? Thanks.
- Aaron
|
|
|
|
|
monrobot13 wrote:
For example if I open the dialog, disable some controls, closed the dialog, then open it again should those controls still be disabled? Thanks.
No. It is re-created from scratch from the .rc file.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Hi,
I was wondering if it was possible to change only one member function in a template specifialization
and have the rest the same without having to duplicate the code in the specifialized class?
Thanks.
|
|
|
|
|
Yes--
Just define the specialization of the function in the header file after the template definition.
Like this:
<br />
template <typename foo> class bar {<br />
public :<br />
int func1() { ... }<br />
int func2() { ... }<br />
...<br />
}<br />
<br />
template<> bar<q>::func2()<br />
{<br />
...<br />
}<br />
|
|
|
|
|
hi me again, ive been writting code that fills a vector with random numbers from two sources, all even elements are filled from source1 and odd ones from source2...this now works fine after much debuggingmyhead.
ive been trying to to do next part of my function which is more complex, it basically uses a iterator with a const value of 0.002. which is 20millseconds.
this iterator goes to every single element in the array and goes through every element in 0.002 segments..i.e if element value is 3.6 then it goes through it in 1,800 segements. basically splitting up the element into segments,
and it does this to distingusih between numbers from sourceone and sourcetwo because these numbers are usesd elsewhere.. i will paste the code which fills the vector and ive COMMENTEDout the 'new' but it doesnt work imnot sure what else to do.
#include <iostream><br />
#include <vector><br />
#include <stdlib><br />
#include <time><br />
#include <numeric><br />
#include <algorithm><br />
#include "exponentialgenerator.h"<br />
<br />
using namespace std;<br />
<br />
ExponentialGenerator one = 1.41;<br />
ExponentialGenerator two = 1.71;<br />
<br />
double nextNumber = reinterpret_cast<double>(one.generate());<br />
<br />
double nextNumber2 = reinterpret_cast<double>(two.generate());<br />
<br />
int counter = 0;<br />
<br />
void fillVectorToSum(vector<double>& v, double sum)<br />
{<br />
<br />
int total = 0;<br />
do {<br />
if (counter++ % 2){<br />
v.push_back(nextNumber);<br />
total += nextNumber;<br />
nextNumber = one.generate();<br />
}<br />
else {<br />
v.push_back(nextNumber2);<br />
total += nextNumber2;<br />
nextNumber2 = two.generate();<br />
}<br />
<br />
} while(total+nextNumber+nextNumber2 <= sum);<br />
if(total < sum)<br />
v.push_back(sum-total);<br />
}<br />
<br />
<br />
int main()<br />
{<br />
<br />
srand((unsigned) time(NULL));<br />
vector<double> v;<br />
fillVectorToSum(v, 30);<br />
<br />
cout << "Number of elements: " << v.size() << "\nTotal: "<br />
<< accumulate(v.begin(), v.end(), 0) << endl;<br />
copy(v.begin(), v.end(), ostream_iterator<double> (cout," "));<br />
<br />
<br />
<br />
<br />
<br />
<br />
}
|
|
|
|
|
I would like to determine if a computer is a member of domain or not.
I tried GetPDC but it seem to be returning the workgroup's name.
Enumerating network is also useless, since it is returning other standalone machine's names.
Any ideas about how to do this?
Orcun Colak
|
|
|
|
|
Use NetWkstaGetInfo() .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|