<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: I made a virtual com port reader program that is in c for linux and mac</title>
		<link>http://forums.leaflabs.com/topic.php?id=201</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:19:18 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=201" rel="self" type="application/rss+xml" />

		<item>
			<title>josheeg on "I made a virtual com port reader program that is in c for linux and mac"</title>
			<link>http://forums.leaflabs.com/topic.php?id=201&amp;page=2#post-1574</link>
			<pubDate>Mon, 04 Oct 2010 09:51:52 +0000</pubDate>
			<dc:creator>josheeg</dc:creator>
			<guid isPermaLink="false">1574@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Well the other way to look at it is I can just write it as a large c program and functions in .c files and header files and not mess with linking libraries.&#60;/p&#62;
&#60;p&#62;The only other bit of code I have for what I am working on is a c file for blind source seperation. On the PC side.&#60;/p&#62;
&#60;p&#62;On the micro side I am getting ready to talk to the ads1298 using the maple.&#60;/p&#62;
&#60;p&#62;So I am looking at &#60;a href=&#34;http://leaflabs.com/docs/maple/spi/&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/maple/spi/&#60;/a&#62;&#60;br /&#62;
I am curious if I can use the hardware SPI functions and the two spi ports to have a loopback. That would be good for testing the communication link before sending it to the ads1298.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "I made a virtual com port reader program that is in c for linux and mac"</title>
			<link>http://forums.leaflabs.com/topic.php?id=201&amp;page=2#post-1553</link>
			<pubDate>Mon, 04 Oct 2010 06:15:16 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">1553@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi Josh,&#60;/p&#62;
&#60;p&#62;Cool!  Glad to hear things are working out for you. Your program in fact seems to be something like what StephenFromNYC was asking about a little while ago --&#60;br /&#62;
&#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=210&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=210&#60;/a&#62;&#60;br /&#62;
(provided, of course, that you spun it out into a library and compiled it as a .dll or .so as appropriate).&#60;/p&#62;
&#60;p&#62;Although, for the record, I'm with Perry that such a library is probably unnecessary vs. just statically linking your PC-side code in with the rest of your program.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>josheeg on "I made a virtual com port reader program that is in c for linux and mac"</title>
			<link>http://forums.leaflabs.com/topic.php?id=201&amp;page=2#post-1487</link>
			<pubDate>Thu, 30 Sep 2010 20:58:59 +0000</pubDate>
			<dc:creator>josheeg</dc:creator>
			<guid isPermaLink="false">1487@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I used approach 3 &#38;amp; nexxt will hook 1 ads1298 to the maple ... the second is still comming together. Next will be your sugjestion A there is a png diagram called layout on my cite.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>josheeg on "I made a virtual com port reader program that is in c for linux and mac"</title>
			<link>http://forums.leaflabs.com/topic.php?id=201&amp;page=2#post-1485</link>
			<pubDate>Thu, 30 Sep 2010 18:34:28 +0000</pubDate>
			<dc:creator>josheeg</dc:creator>
			<guid isPermaLink="false">1485@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Great News! For all modified from maple examples &#38;amp; teensy++ serial bench mark tester serial_listen.c&#60;/p&#62;
&#60;p&#62;The maple talks to the PC in bytes so the numbers in the 8 bits effect output on the pc.&#60;br /&#62;
Next will be to replace the maples possition with the FT2232h and the c code should read from the ft2232h the working code will be placed on my website. &#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://sites.google.com/site/openloopproject/&#34; rel=&#34;nofollow&#34;&#62;https://sites.google.com/site/openloopproject/&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;serial.zip has all of it.&#60;/p&#62;
&#60;p&#62;maple first ...&#60;/p&#62;
&#60;p&#62;blockquote&#60;br /&#62;
unsigned char sensor=0;&#60;br /&#62;
int button=38;&#60;/p&#62;
&#60;p&#62;void setup() {&#60;br /&#62;
  pinMode(button, INPUT);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void loop() {&#60;br /&#62;
   sensor = digitalRead(button);&#60;br /&#62;
   if (sensor==HIGH) sensor=255;&#60;br /&#62;
   if (sensor==LOW) sensor=0;&#60;br /&#62;
  SerialUSB.println(sensor, BYTE);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;/blockquote&#60;/p&#62;
&#60;p&#62;now PC ubuntu linux&#60;/p&#62;
&#60;p&#62;blockquote&#60;br /&#62;
#include &#38;lt;stdio.h&#38;gt;&#60;br /&#62;
#include &#38;lt;stdlib.h&#38;gt;&#60;br /&#62;
#include &#38;lt;string.h&#38;gt;&#60;br /&#62;
#include &#38;lt;sys/types.h&#38;gt;&#60;br /&#62;
#include &#38;lt;sys/stat.h&#38;gt;&#60;br /&#62;
#include &#38;lt;fcntl.h&#38;gt;&#60;br /&#62;
#include &#38;lt;unistd.h&#38;gt;&#60;br /&#62;
#include &#38;lt;termios.h&#38;gt;&#60;/p&#62;
&#60;p&#62;// To compile on Ubuntu:&#60;br /&#62;
//   gcc -O3 -Wall -o serial_listen serial_listen.c&#60;/p&#62;
&#60;p&#62;int main(int argc, char **argv)&#60;br /&#62;
{&#60;br /&#62;
	unsigned char buf[16384];&#60;br /&#62;
	int port;&#60;br /&#62;
	int i=0;&#60;br /&#62;
	long n;&#60;br /&#62;
	struct termios settings;&#60;/p&#62;
&#60;p&#62;	if (argc &#38;lt; 2) {&#60;br /&#62;
		fprintf(stderr, &#34;Example: serial_listen /dev/ttyACM0\n&#34;);&#60;br /&#62;
		fprintf(stderr, &#34;Example: serial_listen /dev/cu.usbmodem12341\n&#34;);&#60;br /&#62;
		return 1;&#60;br /&#62;
	}&#60;/p&#62;
&#60;p&#62;	// Open the serial port&#60;br /&#62;
	port = open(argv[1], O_RDONLY);&#60;br /&#62;
	if (port &#38;lt; 0) {&#60;br /&#62;
		fprintf(stderr, &#34;Unable to open %s\n&#34;, argv[1]);&#60;br /&#62;
		return 1;&#60;br /&#62;
	}&#60;/p&#62;
&#60;p&#62;	// Configure the port&#60;br /&#62;
	tcgetattr(port, &#38;amp;settings);&#60;br /&#62;
	cfmakeraw(&#38;amp;settings);&#60;br /&#62;
	tcsetattr(port, TCSANOW, &#38;amp;settings);&#60;/p&#62;
&#60;p&#62;	// Read data until we get a see the end string or get an error&#60;br /&#62;
	printf(&#34;Reading from %s\n&#34;, argv[1]);&#60;br /&#62;
	while (1) {&#60;br /&#62;
		n = read(port, buf, sizeof(buf));&#60;br /&#62;
		for (i=0; i&#38;lt;n; ++i){&#60;br /&#62;
     			if(buf[i]==0) printf(&#34;1 hello world button up.\n &#34;);&#60;br /&#62;
     			if(buf[i]==255) printf(&#34;128 hello world button down.\n &#34;);&#60;br /&#62;
			}&#60;br /&#62;
		}&#60;/p&#62;
&#60;p&#62;	return 0;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;/blockquote
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "I made a virtual com port reader program that is in c for linux and mac"</title>
			<link>http://forums.leaflabs.com/topic.php?id=201&amp;page=2#post-1481</link>
			<pubDate>Thu, 30 Sep 2010 15:49:44 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">1481@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;josheeg - I am a bit confused as to which parts of the system are working, so may I ask some questions, and suggest somethings that might be easier to test? If they are already tested, that's okay, just say what the results were.&#60;/p&#62;
&#60;p&#62;If it is all working, please ignore this post.&#60;/p&#62;
&#60;p&#62;As I understand the electronics, there is:&#60;br /&#62;
1. an FT2232H connected to a host PC&#60;br /&#62;
2. eight ads1298 chips shifting data into an 8-bit parallel port (FIFO) on the FT2232H&#60;br /&#62;
3. a Maple controlling the ads1298 and FT2232H.&#60;/p&#62;
&#60;p&#62;Have you got pieces of this working? Doing subsystems aims to make things simpler so that parts of the system can be tested and proven.&#60;/p&#62;
&#60;p&#62;Have you tried any of these approaches?&#60;br /&#62;
A. One ads1298 into 1 digital input pin of the Maple, and use the Maple to receive the single data stream, pack it into bytes, and use the Maple-IDE serial monitor (using e.g. .print(value, HEX)) to display the values.&#60;br /&#62;
B. eight ads1298 into 8 digital input pins of the Maple, and use the Maple to receive the data, pack it into bytes to represent each individual ads1298 ADC value, and use the serial monitor to display the values.&#60;br /&#62;
3. use the Maple to pretend to be 8 ads1298 by feeding dummy values into the FT2232H, and use your host program to get the data.&#60;/p&#62;
&#60;p&#62;I recommend going through all three steps, but maybe you have a different way to decompose the system into testable pieces.&#60;br /&#62;
If you have a different approach, would you explain what that is, and what the results were?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "I made a virtual com port reader program that is in c for linux and mac"</title>
			<link>http://forums.leaflabs.com/topic.php?id=201&amp;page=2#post-1477</link>
			<pubDate>Thu, 30 Sep 2010 15:08:52 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">1477@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;crenn - I agree with the cast, but, to be pedantic, this is slightly safer:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;unsigned char fu = &#38;#39;a&#38;#39;;
int bar = (int) fu;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;because, AFAIK, the compiler can assume &#60;code&#62;char&#60;/code&#62; means &#60;code&#62;signed char&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;With signed char, and with the top bit of the char variable &#60;code&#62;fu&#60;/code&#62; set to 1, the compiled code will sign extend &#60;code&#62;fu&#60;/code&#62; on assignment to &#60;code&#62;bar&#60;/code&#62;, to give a negative value to &#60;code&#62;bar&#60;/code&#62;, with the 24 upper bits set to 1.&#60;/p&#62;
&#60;p&#62;It might result in an annoying bug, e.g. trying to combine bytes like:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;char fu0, fu1, fu2, fu3;
   // ... do stuff to get fu0 to fu3
int bar = ((int)fu3) &#38;lt;&#38;lt; 24 &#124;  ((int)fu2) &#38;lt;&#38;lt; 16 &#124;  ((int)fu1) &#38;lt;&#38;lt; 8 &#124;  ((int)fu0);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;will break if any of fu0, fu1, or fu2 contain negative 8-bit values, whereas&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;unsigned char fu0, fu1, fu2, fu3;
   // ... do stuff to get fu0 to fu3
int bar = ((int)fu3) &#38;lt;&#38;lt; 24 &#124;  ((int)fu2) &#38;lt;&#38;lt; 16 &#124;  ((int)fu1) &#38;lt;&#38;lt; 8 &#124;  ((int)fu0);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;would work.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "I made a virtual com port reader program that is in c for linux and mac"</title>
			<link>http://forums.leaflabs.com/topic.php?id=201&amp;page=2#post-1453</link>
			<pubDate>Thu, 30 Sep 2010 01:04:20 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">1453@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Cast the char as int. IE&#60;/p&#62;
&#60;p&#62;char bazza='a';&#60;br /&#62;
int barry;&#60;br /&#62;
barry=(int)bazza;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>josheeg on "I made a virtual com port reader program that is in c for linux and mac"</title>
			<link>http://forums.leaflabs.com/topic.php?id=201&amp;page=2#post-1452</link>
			<pubDate>Thu, 30 Sep 2010 00:59:27 +0000</pubDate>
			<dc:creator>josheeg</dc:creator>
			<guid isPermaLink="false">1452@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I am trying to set a mask to coppy the 0-255 number that is a character into a int so I can OR bits out to create the sensors data.&#60;/p&#62;
&#60;p&#62;But it is not working...&#60;/p&#62;
&#60;p&#62;//set something =0&#60;br /&#62;
//create mask unsigned short int 255 &#38;amp; sensor=something&#60;br /&#62;
//coppy to zeroed int masked character value
&#60;/p&#62;</description>
		</item>
		<item>
			<title>josheeg on "I made a virtual com port reader program that is in c for linux and mac"</title>
			<link>http://forums.leaflabs.com/topic.php?id=201&amp;page=2#post-1448</link>
			<pubDate>Wed, 29 Sep 2010 21:52:14 +0000</pubDate>
			<dc:creator>josheeg</dc:creator>
			<guid isPermaLink="false">1448@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;My program did print the correct data when info was sent from the maple just not the ftdi chip.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>josheeg on "I made a virtual com port reader program that is in c for linux and mac"</title>
			<link>http://forums.leaflabs.com/topic.php?id=201&amp;page=2#post-1446</link>
			<pubDate>Wed, 29 Sep 2010 20:11:00 +0000</pubDate>
			<dc:creator>josheeg</dc:creator>
			<guid isPermaLink="false">1446@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I get this out on gtkterm when selecting /dev/ttyUSB0&#60;br /&#62;
as my com port it is the one for the ft2232h board&#60;/p&#62;
&#60;p&#62;0248... like it shoudl I made the maple toggle one bit of te ft2232h up its port.&#60;/p&#62;
&#60;p&#62;shows up as characters in gtkterm but my program doen't print anything?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>StephenFromNYC on "I made a virtual com port reader program that is in c for linux and mac"</title>
			<link>http://forums.leaflabs.com/topic.php?id=201&amp;page=2#post-1445</link>
			<pubDate>Wed, 29 Sep 2010 20:02:01 +0000</pubDate>
			<dc:creator>StephenFromNYC</dc:creator>
			<guid isPermaLink="false">1445@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hello Josheeg,&#60;/p&#62;
&#60;p&#62;In your posts you might want to try using the blockquote and /blockquote markups (where the markups are preceded by &#38;lt; and followed by &#38;gt;) to make it easier to see where you code starts and stops.&#60;/p&#62;
&#60;p&#62;You used &#34;code&#34;, but I think the indentation is a little easier to see.  It is also useful when you are responding to specific comments made by other.&#60;/p&#62;
&#60;p&#62;I tried to use HTML &#34;&#38;amp;&#34; characters to show you exactly what I mean, but I did not succeed.  Can anyone tell me how to do this on this forum?&#60;/p&#62;
&#60;p&#62;Josheeg, good luck on your serial terminal project.&#60;/p&#62;
&#60;p&#62;Thanks!&#60;/p&#62;
&#60;p&#62;Stephen from NYC
&#60;/p&#62;</description>
		</item>
		<item>
			<title>StephenFromNYC on "I made a virtual com port reader program that is in c for linux and mac"</title>
			<link>http://forums.leaflabs.com/topic.php?id=201&amp;page=2#post-1444</link>
			<pubDate>Wed, 29 Sep 2010 19:59:49 +0000</pubDate>
			<dc:creator>StephenFromNYC</dc:creator>
			<guid isPermaLink="false">1444@http://forums.leaflabs.com/</guid>
			<description>&#60;br /&#62;</description>
		</item>
		<item>
			<title>gbulmer on "I made a virtual com port reader program that is in c for linux and mac"</title>
			<link>http://forums.leaflabs.com/topic.php?id=201#post-1438</link>
			<pubDate>Wed, 29 Sep 2010 13:24:57 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">1438@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Let's try to break the problem into pieces.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;But read() reads returns characters and that would mean it would return the character representation of the number. ... can I setup read differently?&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;The read() system call reads bytes from a file or raw stream without any interpretation or change. It is the appropriate way to read raw binary data.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;Or should I printf some way to make the number show up not the character symbols? Like printing the hex or octal equivalent.???&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;Let's put the problem of how to output the numbers from the host program to one side for a moment, and focus on getting the data across correctly. It may be correct to printf() each 24-bit value, but that depends on what needs to happen to the data once the program has got it.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;Fgetc() fputc() both have characters defined in their name is their a one for 8 bit numbers?&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;The names may be causing some confusion. fgetc() and fputc() both handle a byte (fgetc() can return a non-byte value to signal end of file or an error, too), so they are the ones for 8 bit numbers.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;I think when I set a character to a number it does a character to number conversion.&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;read(), write(), fgetc() and fputc() should not change the binary representation of values written or read from a stream once the stream is set to 'raw' on a normal operating system. So no, if you Serial.print(value, BYTE) the number 0x30, it will not be converted, but will be sent as the byte with hexadecimal value 0x30.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;I think I tried this with the button being what is sent up the maples port that button should be on arduinos. So it printed 1 and 0 instead of 48... the same happens if I toggle the lowest data bit on the usb1232h module with the ft2232h chip on it.&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;I'd need to understand what all of the parts in the stream were to give an answer. A conversion may have happened, or not.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;I read here that I am reading charactrers as if I am reading a file...&#60;br /&#62;
&#60;a href=&#34;http://www.cprogramming.com/tutorial/cfileio.html&#34; rel=&#34;nofollow&#34;&#62;http://www.cprogramming.com/tutorial/cfileio.html&#60;/a&#62;&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;That is correct. Reading and writing characters &#60;em&#62;is&#60;/em&#62; reading and writing bytes.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;Binary Output: For binary File Output you use fread.&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;For FILE* output, you'd use fwrite(), but I think I understand what you mean. fread() and fwrite() work for FILE*.&#60;br /&#62;
But open() does not return a FILE*, it returns a file descriptor (a small integer, which the Operating system uses to keep track of the underlying file).&#60;/p&#62;
&#60;p&#62;I don't think you need to change to using FILE*. You can use open() and read() to get the data into the host program.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;so you can see how if it trys to read 64 and the device sent 64 that would match up over time.&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;Don't focus on the most efficient size to do the transfer. Try to get the program working correctly first. The underlying operating system will be handling buffers, and should smooth things out.&#60;/p&#62;
&#60;p&#62;Try to focus on getting the data blocks communicated correctly, and decode it into something easier to use.&#60;br /&#62;
I'd recommend finding a way to slow down the data rate so that it is easy to test, and ensure everything works correctly.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>josheeg on "I made a virtual com port reader program that is in c for linux and mac"</title>
			<link>http://forums.leaflabs.com/topic.php?id=201#post-1437</link>
			<pubDate>Wed, 29 Sep 2010 12:35:14 +0000</pubDate>
			<dc:creator>josheeg</dc:creator>
			<guid isPermaLink="false">1437@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;If a Maple (or Arduino) were sending the data, then using SerialUSB.print(value, BYTE) sends it as binary data.&#60;/p&#62;
&#60;p&#62;But read() reads returns characters and that would mean it would  return the character representation of the number. ... can I setup read differently?&#60;br /&#62;
Or should I printf some way to make the number show up not the character symbols? Like printing the hex or octal equivalent.???&#60;br /&#62;
Fgetc() fputc() both have characters defined in their name is their a one for 8 bit numbers?&#60;/p&#62;
&#60;p&#62;I think when I set a character to a number it does a character to number conversion.&#60;/p&#62;
&#60;p&#62;That I think is why I did...&#60;br /&#62;
sendata=sendata-48;//make character number into numeric number equivalent&#60;/p&#62;
&#60;p&#62;I think I tried this with the button being what is sent up the maples port that button should be on arduinos. So it printed 1 and 0 instead of 48... the same happens if I toggle the lowest data bit on the usb1232h module with the ft2232h chip on it.&#60;/p&#62;
&#60;p&#62;I read here that I am reading charactrers as if I am reading a file...&#60;br /&#62;
&#60;a href=&#34;http://www.cprogramming.com/tutorial/cfileio.html&#34; rel=&#34;nofollow&#34;&#62;http://www.cprogramming.com/tutorial/cfileio.html&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Binary Output: For binary File Output you use fread.&#60;/p&#62;
&#60;p&#62;The declarations for each are similar:&#60;br /&#62;
size_t fread(void *ptr, size_t size_of_elements, size_t number_of_elements, FILE *a_file);&#60;/p&#62;
&#60;p&#62;The data looks like.: there is 16 differential inputs per adc 8 samples are taken 24 bits per sample or 8x3 bytes eatch + 24 bits of status registers gain GPIO status etc. 24X8=192+24=216 bits per chip 1728 bits per 8 chips at 16ksps.&#60;br /&#62;
Bandwith required 27.648 Mbits per second 3.456 M Bytes per second.&#60;/p&#62;
&#60;p&#62;On teensy++ virtual com port usb serial transfer benchmark is&#60;br /&#62;
1.157 MBytes/sec&#60;br /&#62;
That is why the teensy and maple USB is not fast enough and I had soo much trouble finding a way to get the data to the pc fast enough.The maple controls the System clock or sclk and that same pin actuates the write on the ft2232h.The FT2232H is a USB 2.0 Hi-Speed (480Mb/s) to UART/FIFO IC.&#60;/p&#62;
&#60;p&#62;Page 29 on adobe reader &#38;amp; 29 on the ads1298 data sheet show.&#60;br /&#62;
Most significant bit first, 24 status bits, channel 1 MSB first for all 24 bits eatch, ch2, ch3, ch4, ch5, ch6, ch7, ch8&#60;/p&#62;
&#60;p&#62;(A complication is the read() system call does not have to return the number of bytes requested, it can return fewer. But maybe ignore that for now.)&#60;br /&#62;
This is true but I know for the teensy++ reading 64Bytes at a time is the most efficent transfer of USB data. That is the packet size unless it is larger for High Speed USB it could be....&#60;/p&#62;
&#60;p&#62;so you can see how if it trys to read 64 and the device sent 64 that would match up over time.&#60;br /&#62;
Do I understand what is happening? Mostly every sample is 24 bits there is 8 and before that there is 24 bits of status info transmited MSB first.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "I made a virtual com port reader program that is in c for linux and mac"</title>
			<link>http://forums.leaflabs.com/topic.php?id=201#post-1436</link>
			<pubDate>Wed, 29 Sep 2010 05:13:49 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">1436@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;josheeg - I do not understand exactly what needs to happen to the data once the host has received it.&#60;br /&#62;
I would expect that the 24-bit samples will have to be extracted and turned into 24bit numbers anyway so that they can be used, so I don't feel that is extra work.&#60;/p&#62;
&#60;p&#62;If a Maple (or Arduino) were sending the data, then using SerialUSB.print(value, BYTE) sends it as binary data.&#60;br /&#62;
It is exactly 8 bits of binary data, it has not been converted to a ASCII digit character, so it shouldn't significantly impact the transfer time, because it doesn't cause the data to get bigger or even change.&#60;/p&#62;
&#60;p&#62;So there is no need to do:&#60;br /&#62;
&#60;code&#62;sendata=sendata-48;//make character number into numeric number equivelent&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;that subtracts 48 from a number who's value is in the range 0 to 255, and so creates a number in the range -48 to 207.&#60;/p&#62;
&#60;p&#62;I think I now understand what the data looks like. I think it is 8 ADC's x 24bits/ADC, or 8x3bytes = 24bytes&#60;br /&#62;
The 1st byte contains 8 bits, msb from each ADC, then the next byte is has the msb-1 bit from each of the 8 ADC's, and so on.&#60;/p&#62;
&#60;p&#62;In a pseudo notation, the first byte is&#60;br /&#62;
ADC[7].bit(23) &#38;lt;&#38;lt; 7 &#124;  ADC[6].bit(23) &#38;lt;&#38;lt; 6 &#124;  ADC[5].bit(23) &#38;lt;&#38;lt; 5 &#124;  ADC[4].bit(23) &#38;lt;&#38;lt; 4&#60;br /&#62;
                &#124; ADC[3].bit(23) &#38;lt;&#38;lt; 3 &#124;  ADC[2].bit(23) &#38;lt;&#38;lt; 2 &#124;  ADC[1].bit(23) &#38;lt;&#38;lt; 1 &#124;  ADC[0].bit(23) &#38;lt;&#38;lt; 0 &#124;&#60;br /&#62;
then next is bit 22, and so on, down to bit 0.&#60;/p&#62;
&#60;p&#62;I think I understand why you want to stream it that way.&#60;/p&#62;
&#60;p&#62;If I have understood, what is needed is to read data at the host, and assemble blocks of exactly the right size, which is 24bytes , then extract the 8 x 24-bit values, process them, then move on, and get the next 24byte block.&#60;/p&#62;
&#60;p&#62;(A complication is the read() system call does not have to return the number of bytes requested, it can return fewer. But maybe ignore that for now.)&#60;/p&#62;
&#60;p&#62;Do I understand what is happening?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
