当前位置: 首页>>代码示例>>C++>>正文


C++ file::isEOF方法代码示例

本文整理汇总了C++中file::isEOF方法的典型用法代码示例。如果您正苦于以下问题:C++ file::isEOF方法的具体用法?C++ file::isEOF怎么用?C++ file::isEOF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在file的用法示例。


在下文中一共展示了file::isEOF方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnReceiveMessage

//This function is called everytime a message is received on an input port
//"inPort" will hold the port the message was received by (1, 2, or 3)
//"block" holds an object representing the current script block on the flowchart
//"msg" holds an object representing the message received
//type "block." or "msg." to see a list of available parameters and functions
void OnReceiveMessage(uint8 inPort, ScriptBlock block, Message &msg)
{
    if (!bFileOpen) {
        return;
    }
 
    //Here we pretend that we get some sort of ACK or response from the embedded device that indicates that
    //it is ready to receive the next packet of data containing the firmware image.  Most reprogramming/flash
    //protocols has some sort of similar indicator meaing something to the effect of "read for data".
    //For testing, you can simply use a 29-bit transmitter that sends a packet with ID=1234 at a repeating
    //interval
    if (msg.GetID() == 1234) {
 
        //Prep our data payload packet that will be sent to the embedded device
        Message dataMsg;
        dataMsg.SetID(12345);       
        dataMsg.Set11Bit(0);          //I am assuming its 29-bit CAN messages       
 
        block.PrintOutputText("Sending CAN packet ID=" + dataMsg.GetID() + " with data:", false, false, true, false);
        //Read up to 8 bytes of data from the firmware image to fill the next packet of CAN data   
        int i = 0;
        for (i = 0; i < 8; ++i) {
            if (handle.isEOF()) {   //Check for end of file
                block.PrintOutputText("\nEnd of file reached", false, false, false, true);  //print a message indicating the data
                handle.close();        //Close file and release flag that indicates its open
                bFileOpen = false;
                break;
            }
            uint8 dataByte = handle.readUInt8();  //read a single byte of data from the file
            block.PrintOutputText(" " + dataByte, false, false, true, false);  //print a message indicating the data
            dataMsg.SetData(i, dataByte);  //and store the byte from the file directly into our CAN packet structure       
        }
        block.PrintOutputText("\n", false, false, true, false);
 
        dataMsg.SetDataLength(i);  //set the length to the number of bytes read from the file
 
        //And finally send the data packet
        block.SendMessage(1, dataMsg);               
    }
} 
开发者ID:cancapture,项目名称:CANCapture-Resources,代码行数:45,代码来源:binary-file-read-and-transmit.c


注:本文中的file::isEOF方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。