Hello,

I am currently attempting to write some code in Matlab which will allow me to output information to a USB port (which is changed into a PPM signal however this part is already accomplished by some hardware). I have an example of how to use the PCTx-PC to transmitter interface in Windows but I am working in Linux. http://www.endurance-rc.com/pctx.html I have what may be a relatively simple question. In the example code it has this:

//Send new channel data to the PCTx/Servo Controller

bool controller::send(int delay1, int delay2, int delay3, int delay4, int delay5, int delay6, int delay7, int delay8, int delay9){

	OutputReport[0] = 0;  //do not remove, must be 0



	OutputReport[1] = delay1; //ch1

	OutputReport[2] = delay2; //ch2

	OutputReport[3] = delay3; //ch3



	OutputReport[4] = delay4; //ch4

	OutputReport[5] = delay5; //ch5

	OutputReport[6] = delay6; //ch6



	OutputReport[7] = delay7; //ch7

	OutputReport[8] = delay8; //ch8

	OutputReport[9] = delay9; //ch9



	if(!WriteFile(DeviceHandle, OutputReport, Capabilities.OutputReportByteLength, &BytesWritten, NULL)) {

		CloseHandle(DeviceHandle);

		connected = false;

		return false;

	}



	return true;

}

OutputReport[ ] is a char type and delay is int... So my first question is how does this really work without converting int (4 bytes) into char(1 byte)? The values for int vary between 0 and 255 so does the program simply knock off everything else?

Now in order to output this to the device in Linux/matlab all I need to do is open a handle on the device and simply use the write(handle,value...) and all the hand shaking will be taken care of? If you know of any links that can help me out on this topic that would be great.

#include <iostream>

using namespace std;

int main()
{
    int num = 9;
	cin>>num;
 char x=num;
	cout<<x<<endl;
}

Try that code out entering a certain number each time. Conversion is implicit ,
I think if a number is inputted and number >255,
Then char x=(char)number%255; Is what takes place.
After 255 it again starts back at 0......

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.