Jump to content
The simFlight Network Forums

Arduino Transponder interface FSUIPC


Recommended Posts

I have a transponder that sends digits from arduino via serial which FSUIPC reads. I can parse the serial and see the digits (i.e.:1200) but have a problem controlling the setting.

If I look for a specific string (like 1200) I can then send something specific in ipc.control, like 0x1200 .

For example, this works:

function Arduino_Data(Arduino_Com_Port, datastring, length)

	if (string.find(datastring, "1200")) then  
		ipc.control(65715,0x1200)
	end
end

 

However, doing it this way I would have to look for all variations ox 0000 thru 7777 and write each ipc.control manually.

So I am trying this:

function Arduino_Data(Arduino_Com_Port, datastring, length)
	if (string.find(datastring, "%d")) then
		xpdrcode=tonumber(datastring)
		ipc.control(65715,xpdrcode)
	end
end

The problem is ipc.control requires 0x. I seem to be unable to pass it a variable successfully

I have even tried this to no avail.

function Arduino_Data(Arduino_Com_Port, datastring, length)

	if (string.find(datastring, "%d")) then
		xpdrcode=tonumber(datastring)
		xpdrcodehex=string.format("%x",xpdrcode)
		ipc.control(65715,xpdrcodehex)
	end
end

 

Can anyone provide direction on how to get the proper format for the ipc.control parameter? 

This is my first foray into LUA and I have very limited programming knowledge but it is fun. 

Thanks,

Vin

Edited by vinman1000
Link to post
Share on other sites

You are mixing things up a bit. If your argument string is a hex number (without the leading '0x', try this:

function Arduino_Data(Arduino_Com_Port, datastring, length)

	if (string.find(datastring, "%d")) then
		xpdrcode=tonumber("0x"..datastring)
		ipc.control(65715,xpdrcode)
	end
end

John

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.