<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.robotc.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.robotc.net/w/index.php?title=NXT_I2C_Sensors&amp;feed=atom&amp;action=history</id>
		<title>NXT I2C Sensors - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.robotc.net/w/index.php?title=NXT_I2C_Sensors&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://www.robotc.net/w/index.php?title=NXT_I2C_Sensors&amp;action=history"/>
		<updated>2013-05-20T20:42:55Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.18.0</generator>

	<entry>
		<id>http://www.robotc.net/w/index.php?title=NXT_I2C_Sensors&amp;diff=6385&amp;oldid=prev</id>
		<title>Jwatson: /* sendI2CMsg */</title>
		<link rel="alternate" type="text/html" href="http://www.robotc.net/w/index.php?title=NXT_I2C_Sensors&amp;diff=6385&amp;oldid=prev"/>
				<updated>2012-09-06T14:31:07Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;sendI2CMsg&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 14:31, 6 September 2012&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 215:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 215:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; |-&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; |-&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|''nReplySize'' &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|''nReplySize'' &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;The size &lt;/del&gt;of the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;message being sent&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Specifies the length, in bytes, &lt;/ins&gt;of the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;reply expected from the sensor. &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|[[Data_Types#dataType_int|int]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|[[Data_Types#dataType_int|int]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; |-&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; |-&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 224:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 224:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; |-&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; |-&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; |&amp;lt;syntaxhighlight lang=&amp;quot;robotc&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; |&amp;lt;syntaxhighlight lang=&amp;quot;robotc&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;sendI2CMsg(i2cScanPort, i2cScanDeviceMsg[0], 8);&amp;#160; // send &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;an 8 byte &lt;/del&gt;message from &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;sendI2CMsg(i2cScanPort, i2cScanDeviceMsg[0], 8);&amp;#160; // send &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;a &lt;/ins&gt;message from 'i2cScanDeviceMsg[0]' to &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; // &lt;/del&gt;'i2cScanDeviceMsg[0]' to 'i2cScanPort' (S1)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; //&lt;/ins&gt;'i2cScanPort' (S1)&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, expecting an 8 byte return message&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; |-&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; |-&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jwatson</name></author>	</entry>

	<entry>
		<id>http://www.robotc.net/w/index.php?title=NXT_I2C_Sensors&amp;diff=1836&amp;oldid=prev</id>
		<title>Bfeher: Created page with &quot;&lt;yambe:breadcrumb self=&quot;I2C Sensors&quot;&gt;NXT|NXT&lt;/yambe:breadcrumb&gt;   {| class=&quot;wikiText&quot; |- |''For ROBOTC NXT Sensor ''functions'', check out the [[NXT_Functions_Sensors|NXT Sens...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.robotc.net/w/index.php?title=NXT_I2C_Sensors&amp;diff=1836&amp;oldid=prev"/>
				<updated>2012-04-18T20:24:39Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;yambe:breadcrumb self=&amp;quot;I2C Sensors&amp;quot;&amp;gt;NXT|NXT&amp;lt;/yambe:breadcrumb&amp;gt;   {| class=&amp;quot;wikiText&amp;quot; |- |&amp;#039;&amp;#039;For ROBOTC NXT Sensor &amp;#039;&amp;#039;functions&amp;#039;&amp;#039;, check out the [[NXT_Functions_Sensors|NXT Sens...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;yambe:breadcrumb self=&amp;quot;I2C Sensors&amp;quot;&amp;gt;NXT|NXT&amp;lt;/yambe:breadcrumb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikiText&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|''For ROBOTC NXT Sensor ''functions'', check out the [[NXT_Functions_Sensors|NXT Sensor Functions]] page!''&lt;br /&gt;
&lt;br /&gt;
''For more examples and explanations, head over to [[NXT_Sensors_Overview|NXT Sensors Overview]] page!''&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{tl|1|1}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Information ==&lt;br /&gt;
{| class=&amp;quot;wikiText&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|User programming of NXT digital sensors is for advanced users. The average user will not require this capability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Sensors on the NXT can be either analog or digital sensors.&lt;br /&gt;
*For analog sensors, one of the sensor input wires contains an analog value representing the value of the sensor.&lt;br /&gt;
*Digital sensors are more intelligent and typically contain a microprocessor. The sensor communicates with the NXT using the I2C serial communications protocol.&lt;br /&gt;
&lt;br /&gt;
Each of the four sensor ports on the NXT can be configured as either a digital or analog sensor.&lt;br /&gt;
There are integrated device drivers for the LEGO developed sensors built into the ROBOTC firmware. If an application program wants to provide its own device drivers for either existing or new 3rd party sensors, it is important to set the sensor type to a “custom user provided device driver” so that there are no conflicts between  the built-in device drivers and the user written code. There are four sensor types that are valid for application controlled digital sensors on a NXT. These are:&lt;br /&gt;
:&amp;lt;span class=&amp;quot;keywordRed&amp;quot;&amp;gt;sensorI2CCustomStd&amp;lt;/span&amp;gt;&lt;br /&gt;
::Indicates that user program sensor using standard baud rate communications. Standard communications operates at about 1 byte transferred per millisecond.&lt;br /&gt;
:&amp;lt;span class=&amp;quot;keywordRed&amp;quot;&amp;gt;sensorI2CCustomStd9V&amp;lt;/span&amp;gt;&lt;br /&gt;
::Same as above with the addition that battery voltage (i.e. 9V less the drop through a protection diode) is also provided on pin X for those sensors that want the higher voltage level.&lt;br /&gt;
:&amp;lt;span class=&amp;quot;keywordRed&amp;quot;&amp;gt;sensorI2CCustomFast&amp;lt;/span&amp;gt;&lt;br /&gt;
::Indicates that user program sensor using enhanced baud rate communications. The enhanced baud rate is about five times faster than the standard baud rate. So far, all new 3rd party sensors that have been tested are compatible with the enhanced baud rate; in testing only the LEGO Sonar sensor requires use of the standard baud rate.   &lt;br /&gt;
:&amp;lt;span class=&amp;quot;keywordRed&amp;quot;&amp;gt;sensorI2CCustomFast9V&amp;lt;/span&amp;gt;&lt;br /&gt;
::Same as above with the addition that battery voltage (i.e. 9V less the drop through a protection diode) is also provided on pin X for those sensors that want the higher voltage level.&lt;br /&gt;
&lt;br /&gt;
There are several sample programs in the ROBOTC distribution that illustrate the use of I2C messaging on the NXT with ROBOTC. There are a few things to remember in I2C messaging:&lt;br /&gt;
*The reply bytes from an I2C “read” message are stored in a circular buffer until read by application program.&lt;br /&gt;
*Before sending an I2C “read” message, it is good practice to clear out any reply bytes that exist in the buffer.&lt;br /&gt;
*I2C messaging can be slow. There are several bytes of protocol overhead on every message.&lt;br /&gt;
*In implementing a device driver, it is better to start up a task that continually sends I2C messages to periodically poll the sensor and stores the results. Within the user application it should simply retrieve the last polled value – i.e. no delay – rather than do an inline I2C read to get the sensor value. ROBOTC makes this very easy to achieve by allowing user programs to write as well as read the internal “SensorValue” array. The &amp;quot;SensorValue” array is used to retrieve the value of a sensor from the internal device drivers.&lt;br /&gt;
*You program should accommodate and recover from the occasional I2C messaging error. Lots of testing has indicated that most sensors experience errors rates of 10^-3 to 10^-5.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== nI2CBytesReady ==&lt;br /&gt;
{| style=&amp;quot;color:black;&amp;quot; width=&amp;quot;100%&amp;quot; cellpadding=&amp;quot;5%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;variableType&amp;quot;| &amp;lt;span class=&amp;quot;bigKeywordBI&amp;quot;&amp;gt;word &amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigKeywordB&amp;quot;&amp;gt;nI2CBytesReady&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodePunc&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodeBasic&amp;quot;&amp;gt;tSensors sensor&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodePunc&amp;quot;&amp;gt;]&amp;lt;/span&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;&amp;quot;|([[Data_Types#dataType_word|word]]) Number of queued bytes ready for access from previous I2C read requests.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
  {| class=&amp;quot;parameterTable&amp;quot; cellpadding=&amp;quot;5%&amp;quot; width=&amp;quot;100%&amp;quot;&lt;br /&gt;
  ! width=&amp;quot;20%&amp;quot; style=&amp;quot;border-style: solid; border-width: 0px 0px 1px 0px&amp;quot;|Parameter&lt;br /&gt;
  ! width=&amp;quot;60%&amp;quot; style=&amp;quot;border-style: solid; border-width: 0px 0px 1px 0px&amp;quot;|Explanation&lt;br /&gt;
  ! width=&amp;quot;20%&amp;quot; style=&amp;quot;border-style: solid; border-width: 0px 0px 1px 0px&amp;quot;|Data Type&lt;br /&gt;
  |-&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 1px 0px 0px 0px&amp;quot;|''sensor'' &lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 1px 0px 0px 0px&amp;quot;|A sensor port or name&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 1px 0px 0px 0px&amp;quot;|[[Data_Types#dataType_tSensors|tSensors]]&lt;br /&gt;
  |-&lt;br /&gt;
  |}&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
  {|&lt;br /&gt;
  |-&lt;br /&gt;
  |&amp;lt;syntaxhighlight lang=&amp;quot;robotc&amp;quot;&amp;gt;&lt;br /&gt;
nI2CBytesReady[i2cScanPort] = 0;  // queue no bytes.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
  |-&lt;br /&gt;
  |}&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== nI2CRetries ==&lt;br /&gt;
{| style=&amp;quot;color:black;&amp;quot; width=&amp;quot;100%&amp;quot; cellpadding=&amp;quot;5%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;variableType&amp;quot;| &amp;lt;span class=&amp;quot;bigKeywordBI&amp;quot;&amp;gt;word &amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigKeywordB&amp;quot;&amp;gt;nI2CRetries&amp;lt;/span&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;&amp;quot;|([[Data_Types#dataType_word|word]]) The number of re-transmission attempts that should be made for I2C message.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
  {|&lt;br /&gt;
  |-&lt;br /&gt;
  |&amp;lt;syntaxhighlight lang=&amp;quot;robotc&amp;quot;&amp;gt;&lt;br /&gt;
nI2CRetries = 0;  // do or do not, there is no try&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
  |-&lt;br /&gt;
  |}&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== nI2CStatus ==&lt;br /&gt;
{| style=&amp;quot;color:black;&amp;quot; width=&amp;quot;100%&amp;quot; cellpadding=&amp;quot;5%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;variableType&amp;quot;| &amp;lt;span class=&amp;quot;bigKeywordB&amp;quot;&amp;gt;TI2CStatus &amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigKeywordB&amp;quot;&amp;gt;nI2CStatus&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodePunc&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodeBasic&amp;quot;&amp;gt;tSensors sensor&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodePunc&amp;quot;&amp;gt;]&amp;lt;/span&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;&amp;quot;|([[Data_Types#dataType_TI2CStatus|TI2CStatus]]) Current status of an sensor I2C link.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
  {| class=&amp;quot;parameterTable&amp;quot; cellpadding=&amp;quot;5%&amp;quot; width=&amp;quot;100%&amp;quot;&lt;br /&gt;
  ! width=&amp;quot;20%&amp;quot; style=&amp;quot;border-style: solid; border-width: 0px 0px 1px 0px&amp;quot;|Parameter&lt;br /&gt;
  ! width=&amp;quot;60%&amp;quot; style=&amp;quot;border-style: solid; border-width: 0px 0px 1px 0px&amp;quot;|Explanation&lt;br /&gt;
  ! width=&amp;quot;20%&amp;quot; style=&amp;quot;border-style: solid; border-width: 0px 0px 1px 0px&amp;quot;|Data Type&lt;br /&gt;
  |-&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 1px 0px 0px 0px&amp;quot;|''sensor'' &lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 1px 0px 0px 0px&amp;quot;|A sensor port or name&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 1px 0px 0px 0px&amp;quot;|[[Data_Types#dataType_tSensors|tSensors]]&lt;br /&gt;
  |-&lt;br /&gt;
  |}&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
  {|&lt;br /&gt;
  |-&lt;br /&gt;
  |&amp;lt;syntaxhighlight lang=&amp;quot;robotc&amp;quot;&amp;gt;&lt;br /&gt;
#define i2cScanPort  S1             // port to Scan!&lt;br /&gt;
TI2CStatus nStatus;                 // status variable&lt;br /&gt;
byte replyMsg[10];                  // reply Message byte Array of size 10&lt;br /&gt;
&lt;br /&gt;
nStatus = nI2CStatus[i2cScanPort];  // check the status of the port in question (S1 in this case)&lt;br /&gt;
if(nStatus != NO_ERR)               // if the status is not, 'NO_ERR':&lt;br /&gt;
{&lt;br /&gt;
  return false;              &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
readI2CReply(i2cScanPort, replyMsg[0], 8);  // retrieve 8 reply bytes from 'i2cScanPort' (S1) to 'replyMsg[0]'&lt;br /&gt;
if(replyMsg[0] == 0x00)                     // if the bytes are hexidecimal '0' (0x00):&lt;br /&gt;
{&lt;br /&gt;
  return false;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
  |-&lt;br /&gt;
  |}&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== readI2CReply ==&lt;br /&gt;
{| style=&amp;quot;color:black;&amp;quot; width=&amp;quot;100%&amp;quot; cellpadding=&amp;quot;5%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;functionType&amp;quot;| &amp;lt;span class=&amp;quot;bigKeywordBI&amp;quot;&amp;gt;void &amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigKeywordB&amp;quot;&amp;gt;readI2CReply&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodePunc&amp;quot;&amp;gt;(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigKeywordBI&amp;quot;&amp;gt;const &amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodeBasic&amp;quot;&amp;gt;tSensors nPort&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodePunc&amp;quot;&amp;gt;, &amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigKeywordBI&amp;quot;&amp;gt;byte &amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodeBasic&amp;quot;&amp;gt;&amp;amp;replyBytes&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodePunc&amp;quot;&amp;gt;, &amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigKeywordBI&amp;quot;&amp;gt;const int &amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodeBasic&amp;quot;&amp;gt;nBytesToRead&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodePunc&amp;quot;&amp;gt;)&amp;lt;/span&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;&amp;quot;|([[Data_Types#dataType_void|void]]) Retrieve the reply bytes from an I2C message.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
  {| class=&amp;quot;parameterTable&amp;quot; cellpadding=&amp;quot;5%&amp;quot; width=&amp;quot;100%&amp;quot;&lt;br /&gt;
  ! width=&amp;quot;20%&amp;quot; style=&amp;quot;border-style: solid; border-width: 0px 0px 1px 0px&amp;quot;|Parameter&lt;br /&gt;
  ! width=&amp;quot;60%&amp;quot; style=&amp;quot;border-style: solid; border-width: 0px 0px 1px 0px&amp;quot;|Explanation&lt;br /&gt;
  ! width=&amp;quot;20%&amp;quot; style=&amp;quot;border-style: solid; border-width: 0px 0px 1px 0px&amp;quot;|Data Type&lt;br /&gt;
  |-&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 1px 0px 0px 0px&amp;quot;|''nPort'' &lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 1px 0px 0px 0px&amp;quot;|A sensor port or name&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 1px 0px 0px 0px&amp;quot;|[[Data_Types#dataType_tSensors|tSensors]]&lt;br /&gt;
  |-&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|''replyBytes'' &lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|Where to save the message&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|[[Data_Types#dataType_byte|byte]]&lt;br /&gt;
  |-&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|''nBytesToRead'' &lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|How many bytes to read from message&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|[[Data_Types#dataType_int|int]]&lt;br /&gt;
  |-&lt;br /&gt;
  |}&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
  {|&lt;br /&gt;
  |-&lt;br /&gt;
  |&amp;lt;syntaxhighlight lang=&amp;quot;robotc&amp;quot;&amp;gt;&lt;br /&gt;
#define i2cScanPort  S1             // port to Scan!&lt;br /&gt;
TI2CStatus nStatus;                 // status variable&lt;br /&gt;
byte replyMsg[10];                  // reply Message byte Array of size 10&lt;br /&gt;
&lt;br /&gt;
nStatus = nI2CStatus[i2cScanPort];  // check the status of the port in question (S1 in this case)&lt;br /&gt;
if(nStatus != NO_ERR)               // if the status is not, 'NO_ERR':&lt;br /&gt;
{&lt;br /&gt;
  return false;              &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
readI2CReply(i2cScanPort, replyMsg[0], 8);  // retrieve 8 reply bytes from 'i2cScanPort' (S1) to 'replyMsg[0]'&lt;br /&gt;
if(replyMsg[0] == 0x00)                     // if the bytes are hexidecimal '0' (0x00):&lt;br /&gt;
{&lt;br /&gt;
  return false;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
  |-&lt;br /&gt;
  |}&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== sendI2CMsg ==&lt;br /&gt;
{| style=&amp;quot;color:black;&amp;quot; width=&amp;quot;100%&amp;quot; cellpadding=&amp;quot;5%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| class=&amp;quot;functionType&amp;quot;| &amp;lt;span class=&amp;quot;bigKeywordBI&amp;quot;&amp;gt;void &amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigKeywordB&amp;quot;&amp;gt;sendI2CMsg&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodePunc&amp;quot;&amp;gt;(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigKeywordBI&amp;quot;&amp;gt;const &amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodeBasic&amp;quot;&amp;gt;tSensors nPort&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodePunc&amp;quot;&amp;gt;, &amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigKeywordBI&amp;quot;&amp;gt;const byte &amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodeBasic&amp;quot;&amp;gt;&amp;amp;sendMsg&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodePunc&amp;quot;&amp;gt;, &amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigKeywordBI&amp;quot;&amp;gt;const int &amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodeBasic&amp;quot;&amp;gt;nReplySize&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;bigCodePunc&amp;quot;&amp;gt;)&amp;lt;/span&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;&amp;quot;|([[Data_Types#dataType_void|void]]) Send an I2C message on the specified sensor port.&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
  {| class=&amp;quot;parameterTable&amp;quot; cellpadding=&amp;quot;5%&amp;quot; width=&amp;quot;100%&amp;quot;&lt;br /&gt;
  ! width=&amp;quot;20%&amp;quot; style=&amp;quot;border-style: solid; border-width: 0px 0px 1px 0px&amp;quot;|Parameter&lt;br /&gt;
  ! width=&amp;quot;60%&amp;quot; style=&amp;quot;border-style: solid; border-width: 0px 0px 1px 0px&amp;quot;|Explanation&lt;br /&gt;
  ! width=&amp;quot;20%&amp;quot; style=&amp;quot;border-style: solid; border-width: 0px 0px 1px 0px&amp;quot;|Data Type&lt;br /&gt;
  |-&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 1px 0px 0px 0px&amp;quot;|''nPort'' &lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 1px 0px 0px 0px&amp;quot;|A sensor port or name&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 1px 0px 0px 0px&amp;quot;|[[Data_Types#dataType_tSensors|tSensors]]&lt;br /&gt;
  |-&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|''sendMsg'' &lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|The message to send&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|[[Data_Types#dataType_byte|byte]]&lt;br /&gt;
  |-&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|''nReplySize'' &lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|The size of the message being sent&lt;br /&gt;
  | style=&amp;quot;border-style: solid; border-width: 0px 0px 0px 0px&amp;quot;|[[Data_Types#dataType_int|int]]&lt;br /&gt;
  |-&lt;br /&gt;
  |}&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
  {|&lt;br /&gt;
  |-&lt;br /&gt;
  |&amp;lt;syntaxhighlight lang=&amp;quot;robotc&amp;quot;&amp;gt;&lt;br /&gt;
sendI2CMsg(i2cScanPort, i2cScanDeviceMsg[0], 8);  // send an 8 byte message from &lt;br /&gt;
                                                  // 'i2cScanDeviceMsg[0]' to 'i2cScanPort' (S1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
  |-&lt;br /&gt;
  |}&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bfeher</name></author>	</entry>

	</feed>