On Wednesday 04 July 2012 14:32:06 Schooner did opine:

> Hi
> I have been playing with a C userspace component to pass values from
> Linuxcnc to an arduino for display on a pendant LCD.
> 
> The code works perfectly from a commandline program but when inserted
> into a component, it compiles and runs but each
> write(fd, buff, sizeof(buff)) goes to stdout / stderr instead of the
> place fd points to, which is /dev/ttyUSB0
> 

Basic C stuff AIRemember:

You did #include stdio.h I assume...

And what is the type of 'fd'?  studio.h should define that globally, or did 
the last time I used it. (And I am assuming you are in fact opening a path 
to it prior to the write)

I'm thinking that because of the type you used for 'fd', that it may well 
be volatile, and out of that functions 'scope' by the time you actually do 
the above write.  Some printf's to stdout as to the value of 'fd' may be 
enlightening, bearing in mind that 'fd' should be a pointer, and should 
retain its value when printf'd in the next line after the open, and should 
be identical in a printf in front of your write, both as 'fd' and as '*fd'.

OTOH its been much of a decade since I last carved any fresh C, so my 
ancient memory could well be full of it.

> I can connect to a socket server from within the userspace component
> and pass the values indirectly, but it is bugging me to distraction that
> perfectly normal serial comms code which can be shown to work elsewhere
> will not work properly in the component.
> 
> If anyone has any ideas why this should be, I would be grateful!
> 
> regards
> 
> ------------------------------------------------------------------------
> ------ Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond.
> Discussions will include endpoint security, mobile security and the
> latest in malware threats.
> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Emc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/emc-users


Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
My web page: <http://coyoteden.dyndns-free.com:85/gene> is up!
Democracy is a government where you can say what you think even if you
don't think.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to