Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am wanting to create a c++ program that will power cables.Like a ethernet cable has several wires in it.How would I choose a wire and send current through it?
If anyone can explain how to send current over specific wires that would be great.I also do not want to use a library.To make it even clearer , I wish to be able to do something like this [Video] https://www.youtube.com/watch?v=H1enhkLZm10 .
I guess this will answer your question: I/O Ports controlled LEDs.
This is a code snippet from the website on how to communicate with a port:
#include <conio.h>
#include <dos.h> // For _out
#define port 0x378 // Port Address
#define data port+0 // Data Port of the parallel cable
void main (void)
{
_out(data, 255); // For all lights on
_out(data, 0); // For all lights off
}
If you don't know how computers communicate with peripherals, and how different ports like USB(Universal Serial Bus), Serial ports, and other ports communicate and work. This guide should help you get started.Control Physical World Through Computer (Step by Step)
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have an assignment that I need to write a program that opens a port in the network, than I should check if the port is opened in another machine using nmap or netcat.
Well, I already did that.. but I did it using socket, I created a socket then binded and keep listening, that's the only way I know to do it. is there a better way ? because my way doesn't seem write..
Also, is opening a port for TCP is different then a port for UDP ?
Note: I'm trying to figure out how to write a program that open a port in C/C++, but Python or Java are fine too..
Edit: I'm fine with TCP, but still didn't figure out how to open a port for UDP. Since there's no "listen" in UDP, how am I supposed to keep the port open ? I wrote a program that creates a socket for UDP and binds it, but when I scan it with nmap, it says "open/filtered", how am I supposed to make it only Open ?
That is the correct way to "open" a port.
A port is called "open" if something is listening on it. So, by definition, you need to listen on a port for it to become open.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to make a socks 4 proxy server with boost-asio. How can i connect to the site specified by the client if its in network byte order? Can you please provide examples. I'm using a linux so no winsock.
sock4request is what the server receive from the client.
const boost::array<unsigned char,4> addr={sock4request[5],sock4request[6],sock4request[7],sock4request[8]}; //Network byte address
unsigned char port[]={sock4request[3],sock4request[4]};
boost::asio::ip::address_v4 addrip(addr);
unsigned short portint=lexical_cast<unsigned short>(port);
tcp::endpoint addrinfo(addrip,portint);
tcp::socket finalsocket(io_service);
boost::asio::connect(finalsocket,endpoint_iterator);
You should use the built-in linux functions like htons, ntohs..
Please review this page:
http://www.beej.us/guide/bgnet/output/html/multipage/htonsman.html
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
For my thesis I'm given an application written in visual c++ and using MFC that receives gps data (NMEA 183 (RMC)), the data is received from UDP and/or a Serial port (COM port) (they have to work separatly or together). The UDP part of the application is done and its working (written by another student before me), so I have to finish the Serial port part, but here comes my problem, it turns out that MFC does not support COM ports or at least doesn't have a class for serial ports, I found some serial port implementation on the internet: LINK, but I dont know how to integrate it and make it work, it turns out that the UDP part is working like an event triggering mechanism using virtual function CAsyncSocket::OnReceive. I was wondering if its posible to make anything similar to this working with Serial Ports?
Thank you for your help.
Best Regards.
If your program is a GUI then it is a good idea to run the serial port code in a separate worker thread. ReadFile can take a long time to get serial data and this would block the GUI message processing if it was done in the main thread. To provide notification events from the serial thread to the main (GUI) thread you can use PostMessage with a user-defined message. An example of doing this is at
http://vcfaq.mvps.org/mfc/12.htm
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have a motor connected to my computer, which is connected through CAN to the motor. Basically, I have a USB-to-CAN adapter, to which I connect a USB cable from my computer. Then, from the adapter, the motor is connected through CAN.
Now, I wish to send data to the motor- I already know what sequence of bytes I need to send, but I'm not sure what commands to use to "talk" to my motor that is connected through CAN. I have been able to send data by direct USB connection from my computer to motor (using the WriteFile command in C++), but this method does not work for CAN.
Are there any libraries/functions that I can use to talk to my motor via CAN in C++?
Since you cannot connect a motor directly to a CAN bus, there must be some sort of motor controller, drive or I/O controller between the bus. Details of this device are required in order to advise on a more than fundamental level.
CAN itself does not define an application layer protocol, and several application protocols exist for CAN, such as CANopen, DeviceNet and SDS. Your device may use such a protocol or possibly something entirely proprietary. Your starting point should be the documentation for your I/O device.
For testing, most PC CAN adapter manufacturers will provide some sort of debug or development tool that allows you to construct and send individual messages and message sequences at a low-level; such a tool will allow you to verify the operation of the bus and I/O device.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Hi I have a PC(A) that receive data via TCP and need forward them to other PC(B)server.
The problem is PC(B) server can open only few sessions about 5 and we need to connect it to about 100 clients and we want to do it via PC(A) that read data and add id to data and forward it to server.
for do that I write a simple tcp server(run on PC A), that read data from TCP stack and forward it to PC(B)
I accept the connection on an open socket and forward it to PC(B).
In this PC(A) take about 200 μs to do this data forwarding. I have 3 GHZ * 10 and I use fedora OS, my data is so small.
How I can decrease this latency?
Do I need to change my OS or make any optimization that decreases this latency?