Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.17/5 (5 votes)
See more:
Hi Just wondering if any one has any experience of writing a code in C/C++ for data transmission between PCs using laser. I am not looking for anything overy complicated, just want to have a 'starting' code or a template if you will to build upon.
I am attempting to accomplish data transmission and incorporate a data detection/correction mechanism, preferably based on Hamming codes. If you have the experience or have come across anything like this please help me out - my web serch didn't result in anything useful, not at least for a C beginner that I am.
Advance thanks,
Joao

[From "solution"]
Thanks for the prompt reply. Yes - apologies for the confusion. The question does sound hardware-related but it's the software that I'm more worried about. I am attempting to do wireless transmission of data using a laser beam from a pointer (as you have mentioned) to be received at the other end by a photo-resistor. Never mind the hardware though (not at least at this point), I am looking for a C code that enables the transmission of data from one PC to another with an incorporated error detection/correction mechanism. I am a beginner in the C language, so just wondering whether you or indeed anyone else can provide me with a 'starting' C code/template?
Many thanks,
Posted
Updated 3-Aug-12 7:16am
v2
Comments
lewax00 3-Aug-12 13:07pm    
Using laser how? Via fiber optic cables? A servo pressing a button on a laser pointer with a photoresistor on the other end? You're asking a question that appears to relate to hardware, but you haven't stated what the hardware is.
figueira j 3-Aug-12 13:26pm    
Thanks for the prompt reply. Yes - apologies for the confusion. The question does sound hardware-related but it's the software that I'm more worried about. I am attempting to do wireless transmission of data using a laser beam from a pointer (as you have mentioned) to be received at the other end by a photo-resistor. Never mind the hardware though (not at least at this point), I am looking for a C code that enables the transmission of data from one PC to another with an incorporated error detection/correction mechanism. I am a beginner in the C language, so just wondering whether you or indeed anyone else can provide me with a 'starting' C code/template?
Many thanks, .
pasztorpisti 3-Aug-12 13:33pm    
We have to know the hardware because the whole solution depends on it. If your data flow is just one way (half duplex connection) then you can put in some error detection and can tweak the transfer parameters (baudrate) but the chance of an uncorrectable error on the other side will never be zero. All you can do is to provide an error correction scheme that is good enough to keep the probability of a fatal error below an epsilon value.
figueira j 3-Aug-12 13:39pm    
Many thanks for your informative reply. It is a half duplex connection I am wishing to establish so that error detection, and correction (to the highest possible extent) can be incorporated. I was considering the Hamming code as a good option. Do you agree with this as being a good choice and now that I have (hopefuly) clarified the hardware setting (short-distance it will be) can you please guide me to a suitable starting code in C?
Thanks a lot,
pasztorpisti 3-Aug-12 13:41pm    
We still don't know the features of your hardware so we couldn't send you code even if we wanted... :-)

It might be overkill for what you're doing, but you could look into using TCP[^], it has some basic error checking and recovery built in, and there should be plenty of support for it in C (this[^] has some sample code, though I don't have any experience in using TCP directly so I have no idea if it's any good, but Google turned up over 61 million results for "tcp in c").
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 3-Aug-12 13:48pm    
This is not an overkill at all!

For a long time, I tried hard to convince people to eliminate all those trash controller communication methods like COM/Serial ports, FireWire and anything based on PCI cards from embedded systems. Working with TCP is the best, and you can implement decent push technology and inversion of control, not wasting resources and CPU on idiotic polling. Probably, another viable option is USB, but I would strongly prefer Ethernet.

People argued that Ethernet-based controllers are cheaper, but this is the fictional saving. If you get rid of everything but Ethernet, you can purchase cheaper industrial PCs in a really small form-factor, without unwanted connectors and save a lot more, not even mentioning much greater savings on software development and software quality gains. Truly, the miser pays twice!

--SA
Sergey Alexandrovich Kryukov 3-Aug-12 13:50pm    
I voted 5, but, to be fair, this is not really an answer; at the same time, this is not your fault, because it needs a lot more information on OP's goals, hardware, etc., to get any real advice. As for now, the question simply makes too little sense.
--SA
lewax00 3-Aug-12 13:55pm    
Thanks. The best I can tell is he's more concerned about the transmission protocol, and off the top of my head TCP was the first one I could think of with any sort of error checking. But I agree, more details are needed for a more appropriate answer.
Sergey Alexandrovich Kryukov 3-Aug-12 13:59pm    
Of course. You are very welcome.
--SA
 
Share this answer
 
Please visit the Site To learn Fundamentals of C Programming online video tutorials in Tamil. It is very useful for the Beginners.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900