Neuron C Reference Guide Iii • Introduction to the LONWORKS Platform (078-0391-01A)
Total Page:16
File Type:pdf, Size:1020Kb
Neuron C Provides reference info for writing programs using the Reference Guide Neuron C programming language. 078-0140-01G Echelon, LONWORKS, LONMARK, NodeBuilder, LonTalk, Neuron, 3120, 3150, ShortStack, LonMaker, and the Echelon logo are trademarks of Echelon Corporation that may be registered in the United States and other countries. Other brand and product names are trademarks or registered trademarks of their respective holders. Neuron Chips and other OEM Products were not designed for use in equipment or systems, which involve danger to human health or safety, or a risk of property damage and Echelon assumes no responsibility or liability for use of the Neuron Chips in such applications. Parts manufactured by vendors other than Echelon and referenced in this document have been described for illustrative purposes only, and may not have been tested by Echelon. It is the responsibility of the customer to determine the suitability of these parts for each application. ECHELON MAKES AND YOU RECEIVE NO WARRANTIES OR CONDITIONS, EXPRESS, IMPLIED, STATUTORY OR IN ANY COMMUNICATION WITH YOU, AND ECHELON SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of Echelon Corporation. Printed in the United States of America. Copyright © 2006, 2014 Echelon Corporation. Echelon Corporation www.echelon.com Welcome This manual describes the Neuron® C Version 2.3 programming language. It is a companion piece to the Neuron C Programmer's Guide. It provides reference information for writing programs using Neuron C. Neuron C is a programming language based on ANSI C that is designed for applications that run on Neuron Chips and Smart Transceivers (Neuron-hosted devices). Neuron C includes network communication, I/O, and event-handling extensions to ANSI C, which make it a powerful tool for the development of LONWORKS® applications. A subset of the Neuron C language is also used to describe the interoperable interface of host-based applications that are designed with the ShortStack® Developer’s Kit, FTXL™ Developer’s Kit, or the i.LON® SmartServer. This interoperable interface is contained within a file called a model file, which contains Neuron C declarations and definitions for the device interface. This guide focuses on the Neuron C language used for Neuron-hosted application development, and only highlights differences for model file compilation where necessary. Audience The Neuron C Programmer’s Guide is intended for application programmers who are developing LONWORKS applications. Readers of this guide are assumed to be familiar with the ANSI C programming language, and have some C programming experience. For a complete description of ANSI C, consult the following references: • —. 1989. American National Standard for Information Systems Programming Language C. Standard number X3.159-1989. New York, NY: American National Standards Institute. • —. 2007. International Standard ISO/IEC 9899:1999. Programming languages – C. Geneva, Switzerland: International Organization for Standardization. • Harbison, Samuel P. and Guy L. Steele, Jr. 2002. C: A Reference Manual, 5th edition. Upper Saddle River, NJ: Prentice Hall, Inc. • Kernighan, Brian W. and Dennis M. Ritchie. 1988. The C Programming Language, 2nd edition. Upper Saddle River, NJ: Prentice Hall, Inc. • Plauger, P.J. and Jim Brodie. 1989. Standard C: Programmer’s Quick Reference Series. Buffalo, NY: Microsoft Press. • Plauger, P.J. and Jim Brodie. 1992. ANSI and ISO Standard C Programmer's Reference. Buffalo, NY: Microsoft Press. Related Documentation The following manuals are available from the Echelon Web site (www.echelon.com) and provide additional information that can help you develop Neuron C applications for LONWORKS devices: Neuron C Reference Guide iii • Introduction to the LONWORKS Platform (078-0391-01A). This manual provides an introduction to the ISO/IEC 14908 (ANSI/CEA-709.1 and EN14908) Control Network Protocol, and provides a high-level introduction to LONWORKS networks and the tools and components that are used for developing, installing, operating, and maintaining them. • I/O Model Reference for Smart Transceivers and Neuron Chips (078- 0392-01C). This manual describes the I/O models that are available for Echelon’s Smart Transceivers and Neuron Chips. • IzoT Commissioning Tool User's Guide (078-0514-01 ). This manual describes how to use the Izot Commissioning Tool to design, commission, monitor and control, maintain, and manage a LONWORKS network. • LONMARK® Application Layer Interoperability Guidelines. This manual describes design guidelines for developing applications for open interoperable LONWORKS devices, and is available from the LONMARK Web site, www.lonmark.org. • Neuron C Programmer’s Guide (078-0002-01I). This manual describes how to write programs using the Neuron C Version 2.3 programming language. • Neuron Tools Errors Guide (078-0402-01D). This manual documents and explains the various warning and error messages that can occur for the various Neuron C development tools. • IzoT NodeBuilder FX User’s Guide ( 078-0516-01). This manual describes how to develop a LONWORKS device using the IzoT NodeBuilder tool. All of the Echelon documentation is available in Adobe PDF format. To view the PDF files, you must have a current version of the Adobe Reader, which you can download from Adobe at: www.adobe.com/products/acrobat/readstep2.html. Typographic Conventions for Syntax Table 1 lists the typographic conventions used in this manual for displaying Neuron C syntax: Table 1. Typographic Conventions Typeface or Symbol Used for Example boldface type keywords network literal characters { italic type abstract elements identifier [square brackets] optional fields [bind-info] iv Typeface or Symbol Used for Example | vertical bar a choice between two input | output elements Example: The syntax for declaring a network variable is: network input | output [netvar modifier] [class] type [bind-info] identifier • You type the keywords network, input, and output as shown • You replace the abstract elements netvar modifier, class, type, bind-info, and identifier with the actual modifier, class, type, bind information, and identifier for the network variable • The declaration must include either input or output, but not both • The elements netvar modifier, class, and bind-info are all optional When a particular element or expression includes punctuation, such as quotation marks, parentheses, and semicolons (but not including square brackets and vertical bars), you must type that punctuation as shown. Code examples appear in the monospace Courier font: #include <mem.h> unsigned array1[40], array2[40]; // See if array1 matches array2 if (memcmp(array1, array2, 40) != 0) { // The contents of the two areas do not match } Neuron C Reference Guide v Table of Contents Welcome ......................................................................................................... iii Audience ........................................................................................................ iii Related Documentation ................................................................................ iii Typographic Conventions for Syntax ........................................................... iv Neuron C Overview ..................................................................................... xix Chapter 1. Predefined Events ........................................................................ 1 Introduction to Predefined Events ................................................................ 2 Event Directory .............................................................................................. 3 flush_completes Event............................................................................. 3 Syntax ................................................................................................ 3 Example ............................................................................................. 3 io_changes Event ..................................................................................... 3 Syntax ................................................................................................ 4 Example 1 .......................................................................................... 4 Example 2 .......................................................................................... 5 io_in_ready Event .................................................................................... 5 Syntax ................................................................................................ 5 Example ............................................................................................. 5 io_out_ready Event .................................................................................. 5 Syntax ................................................................................................ 5 Example ............................................................................................. 5 io_update_occurs Event ........................................................................... 6 Syntax ................................................................................................ 6 Example ............................................................................................