static void Main(string[] args) { try { //create a Serial Connection with the specified COM Port, default baud rate of 921600 mscl.Connection connection = mscl.Connection.Serial(COM_PORT); //create a BaseStation with the connection mscl.BaseStation baseStation = new mscl.BaseStation(connection); //create a WirelessNode with the BaseStation we created mscl.WirelessNode node = new mscl.WirelessNode(NODE_ADDRESS, baseStation); //run the example showing how to retrieve the Node's current configuration getCurrentConfig(ref node); //run the example showing how to update/change the Node's current configuration setCurrentConfig(ref node); } catch (mscl.Error e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Press Enter to quit..."); Console.Read(); }
public static void pingNode(mscl.WirelessNode node) { mscl.PingResponse response = node.ping(); if (response.success()) { //get some details from the response Console.WriteLine("Successfully pinged Node " + node.nodeAddress()); Console.WriteLine("Base Station RSSI: " + response.baseRssi()); Console.WriteLine("Node RSSI: " + response.nodeRssi()); //we can talk to the Node, so let's get some more info Console.WriteLine("Node Information: "); Console.WriteLine("Model Number: " + node.model()); Console.WriteLine("Serial: " + node.serial()); Console.WriteLine("Firmware: " + node.firmwareVersion()); } else { //Note: In order to communicate with a Wireless Node, all of the following must be true: // - The Node is powered on, and within range of the BaseStation // - The Node is on the same frequency as the BaseStation // - The Node is in Idle Mode (not sampling, and not sleeping) // - The Node is on the same communication protocol as the BaseStation (LXRS vs LXRS+) Console.WriteLine("Failed to ping Node " + node.nodeAddress() + "."); } }
static void Main(string[] args) { try { //create a Serial Connection with the specified COM Port, default baud rate of 921600 mscl.Connection connection = mscl.Connection.Serial(COM_PORT); //create a BaseStation with the connection mscl.BaseStation baseStation = new mscl.BaseStation(connection); //create a WirelessNode with the BaseStation we created mscl.WirelessNode node = new mscl.WirelessNode(NODE_ADDRESS, baseStation); //create a SyncSamplingNetwork object, giving it the BaseStation that will be the master BaseStation for the network mscl.SyncSamplingNetwork network = new mscl.SyncSamplingNetwork(baseStation); //add a WirelessNode to the network // Note: The Node must already be configured for Sync Sampling before adding to the network, or else Error_InvalidConfig will be thrown. //TODO: Repeat this for all WirelessNodes that you want in the network Console.Write("Adding node to the network..."); network.addNode(node); Console.WriteLine("Done."); //can get information about the network Console.WriteLine("Network info: "); Console.WriteLine("Network OK: " + network.ok().ToString()); Console.WriteLine("Percent of Bandwidth: " + network.percentBandwidth().ToString() + "%"); Console.WriteLine("Lossless Enabled: " + network.lossless().ToString()); //apply the network configuration to every node in the network Console.Write("Applying network configuration..."); network.applyConfiguration(); Console.WriteLine("Done."); //start all the nodes in the network sampling. The master BaseStation's beacon will be enabled with the system time. // Note: if you wish to provide your own start time (not use the system time), pass a mscl::Timestamp object as a second parameter to this function. // Note: if you do not want to enable a beacon at this time, use the startSampling_noBeacon() function. (A beacon is required for the nodes to actually start sending data). Console.Write("Starting the network..."); network.startSampling(); Console.WriteLine("Done."); //======================================================================================= //Many other functions are available for the SyncSamplingNetwork: // //network.lossless() //enable or disable "lossless" mode for the network (default of enabled). //network.ok() //check whether or not the network is "OK" meaning all nodes fit in the network and have communicated successfully. //network.percentBandwidth() //get the percent of bandwidth for the entire network. //network.refresh() //refreshes the entire network. Should be called any time a change is made to the node after it has been added to the network. //network.removeNode() //remove a node from the network. //network.getNodeNetworkInfo() //get network information for an individual node in the network (TDMA address, percent bandwidth, etc.) //======================================================================================= } catch (mscl.Error e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Press Enter to quit..."); Console.Read(); }
static void Main(string[] args) { try { //create a Serial Connection with the specified COM Port, default baud rate of 921600 mscl.Connection connection = mscl.Connection.Serial(COM_PORT); //create a BaseStation with the connection mscl.BaseStation baseStation = new mscl.BaseStation(connection); //create a WirelessNode with the BaseStation we created mscl.WirelessNode node = new mscl.WirelessNode(NODE_ADDRESS, baseStation); //call the stop function and get the resulting StopNodeStatus object mscl.StopNodeStatus stopStatus = node.stop(); Console.Write("Stopping Node"); //using the StopNodeStatus object, check if the Stop Node operation is complete. // Note: we are specifying a timeout of 300 milliseconds here which is the maximum // amount of time that the complete function will block if the Stop Node // operation has not finished. Leaving this blank defaults to a timeout of 10ms. while (!stopStatus.complete(300)) { //Note: the Stop Node operation can be canceled by calling stopStatus.cancel() Console.Write("."); } //at this point, the Stop Node operation has completed //check the result of the Stop Node operation switch (stopStatus.result()) { //Stop Node completed successfully case mscl.StopNodeStatus.StopNodeResult.stopNodeResult_success: Console.WriteLine("Successfully stopped the Node!"); break; //Stop Node has been canceled by the user case mscl.StopNodeStatus.StopNodeResult.stopNodeResult_canceled: Console.WriteLine("Stop Node was canceled!"); break; //Failed to perform the Stop Node operation case mscl.StopNodeStatus.StopNodeResult.stopNodeResult_failed: default: Console.WriteLine("Stop Node has failed!"); break; } } catch (mscl.Error e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Press Enter to quit..."); Console.Read(); }
static void Main(string[] args) { try { //create a Serial Connection with the specified COM Port, default baud rate of 921600 mscl.Connection connection = mscl.Connection.Serial(COM_PORT); //create a BaseStation with the connection mscl.BaseStation baseStation = new mscl.BaseStation(connection); //create a WirelessNode with the BaseStation we created mscl.WirelessNode node = new mscl.WirelessNode(NODE_ADDRESS, baseStation); //call the set to idle function and get the resulting SetToIdleStatus object mscl.SetToIdleStatus status = node.setToIdle(); Console.Write("Setting Node to Idle"); //using the SetToIdleStatus object, check if the Set to Idle operation is complete. // Note: we are specifying a timeout of 300 milliseconds here which is the maximum // amount of time that the complete function will block if the Set to Idle // operation has not finished. Leaving this blank defaults to a timeout of 10ms. while (!status.complete(300)) { //Note: the Set to Idle operation can be canceled by calling status.cancel() Console.Write("."); } //at this point, the Set to Idle operation has completed //check the result of the Set to Idle operation switch (status.result()) { //completed successfully case mscl.SetToIdleStatus.SetToIdleResult.setToIdleResult_success: Console.WriteLine("Successfully set to idle!"); break; //canceled by the user case mscl.SetToIdleStatus.SetToIdleResult.setToIdleResult_canceled: Console.WriteLine("Set to Idle was canceled!"); break; //Failed to perform the operation case mscl.SetToIdleStatus.SetToIdleResult.setToIdleResult_failed: default: Console.WriteLine("Set to Idle has failed!"); break; } } catch (mscl.Error e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Press Enter to quit..."); Console.Read(); }
private void Set_Idle() { do { switch (num_node) { case 1: node = node1; break; case 2: node = node2; break; case 3: node = node3; break; case 4: node = node4; break; case 5: node = node5; break; } try { zmien_richTextBox1(" Set to Idle"); mscl.SetToIdleStatus status = node.setToIdle(); while (!status.complete(300)) { Console.Write("."); } switch (status.result()) { case mscl.SetToIdleStatus.SetToIdleResult.setToIdleResult_success: break; case mscl.SetToIdleStatus.SetToIdleResult.setToIdleResult_canceled: break; case mscl.SetToIdleStatus.SetToIdleResult.setToIdleResult_failed: default: break; } } catch (mscl.Error err) { zmien_richTextBox1("Error: " + err.Message); } num_node++; } while (num_node < 6); }
static void Main(string[] args) { try { //create a Serial Connection with the specified COM Port, default baud rate of 921600 mscl.Connection connection = mscl.Connection.Serial(COM_PORT); //create a BaseStation with the connection mscl.BaseStation baseStation = new mscl.BaseStation(connection); //create a WirelessNode with the BaseStation we created mscl.WirelessNode node = new mscl.WirelessNode(NODE_ADDRESS, baseStation); //TODO: add as many other WirelessNode objects here as you want (used in the startSyncSampling example) List <mscl.WirelessNode> networkNodes = new List <mscl.WirelessNode>(); networkNodes.Add(node); //due to the nature of wireless devices, it is possible to lose packets over the air. //MSCL has a built in way of performing retries whenever an eeprom address is attempted to be read. //By default, this value is set to 0. You may wish to keep it at 0 and handle retries yourself depending on your application. baseStation.readWriteRetries(3); node.readWriteRetries(3); //TODO: Uncomment the lines below to run the examples //Example: Ping Node //Example1.pingNode(node); //Example: Get Configuration //Example2.getCurrentConfig(node); //Example: Set Configuration //Example3.setCurrentConfig(node); //Warning: this example changes settings on your Node! //Example: Start Sampling //Example4.startSyncSampling(baseStation, networkNodes); //Example: Set to Idle //Example5.setToIdle(node); //Example: Parse Data //Example6.parseData(baseStation); //Example: Enable and Disable Beacon //Example7.enableDisableBeacon(baseStation); } catch (mscl.Error e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Press Enter to quit..."); Console.Read(); }
private void create_conection() { //create a Serial Connection with the specified COM Port, default baud rate of 921600 connection = mscl.Connection.Serial(ports[0]); //create a BaseStation with the connection baseStation = new mscl.BaseStation(connection); //create a WirelessNode with the BaseStation we created node1 = new mscl.WirelessNode(NODE_ADDRESS1, baseStation); node2 = new mscl.WirelessNode(NODE_ADDRESS2, baseStation); node3 = new mscl.WirelessNode(NODE_ADDRESS3, baseStation); node4 = new mscl.WirelessNode(NODE_ADDRESS4, baseStation); node5 = new mscl.WirelessNode(NODE_ADDRESS5, baseStation); node_set = 1; Set_Idle(); //create a SyncSamplingNetwork object, giving it the BaseStation that will be the master BaseStation for the network mscl.SyncSamplingNetwork network = new mscl.SyncSamplingNetwork(baseStation); //add a WirelessNode to the network // Note: The Node must already be configured for Sync Sampling before adding to the network, or else Error_InvalidConfig will be thrown. //TODO: Repeat this for all WirelessNodes that you want in the network zmien_richTextBox1("Adding node to the network.."); network.addNode(node1); network.addNode(node2); network.addNode(node3); network.addNode(node4); network.addNode(node5); //can get information about the network zmien_richTextBox1("\n Network info: "); zmien_richTextBox1("\n Network OK: " + network.ok().ToString()); zmien_richTextBox1("\n Percent of Bandwidth: " + network.percentBandwidth().ToString() + "%"); zmien_richTextBox1("\n Lossless Enabled: " + network.lossless().ToString()); zmien_richTextBox1("\n High Capacity Mode: " + network.highCapacity().ToString()); //apply the network configuration to every node in the network zmien_richTextBox1("\n Applying network configuration..."); network.applyConfiguration(); zmien_richTextBox1(" \n Done."); //start all the nodes in the network sampling. The master BaseStation's beacon will be enabled with the system time. // Note: if you wish to provide your own start time (not use the system time), pass a mscl::Timestamp object as a second parameter to this function. // Note: if you do not want to enable a beacon at this time, use the startSampling_noBeacon() function. (A beacon is required for the nodes to actually start sending data). zmien_richTextBox1(" \n Starting the network..."); network.startSampling(); zmien_richTextBox1(" \n Done."); }
public static void setCurrentConfig(mscl.WirelessNode node) { //many other settings are available than shown below //reference the documentation for the full list of commands Console.WriteLine("Changing configuration settings."); //create a WirelessNodeConfig which is used to set all node configuration options mscl.WirelessNodeConfig config = new mscl.WirelessNodeConfig(); //set some of the node's configuration options config.defaultMode(mscl.WirelessTypes.DefaultMode.defaultMode_idle); config.inactivityTimeout(7200); config.samplingMode(mscl.WirelessTypes.SamplingMode.samplingMode_sync); config.sampleRate(mscl.WirelessTypes.WirelessSampleRate.sampleRate_256Hz); config.unlimitedDuration(true); //attempt to verify the configuration with the Node we want to apply it to // Note that this step is not required before applying, however the apply will throw an // Error_InvalidNodeConfig exception if the config fails to verify. mscl.ConfigIssues issues = new mscl.ConfigIssues(); if (!node.verifyConfig(config, issues)) { Console.WriteLine("Failed to verify the configuration. The following issues were found:"); //print out all of the issues that were found foreach (var issue in issues) { Console.WriteLine(issue.description()); } Console.WriteLine("Configuration will not be applied."); } else { //apply the configuration to the Node // Note that if this writes multiple options to the Node. // If an Error_NodeCommunication exception is thrown, it is possible that // some options were successfully applied, while others failed. // It is recommended to keep calling applyConfig until no exception is thrown. node.applyConfig(config); } Console.WriteLine("Done."); }
public static void getCurrentConfig(mscl.WirelessNode node) { Console.WriteLine("Current Configuration Settings"); //read some of the current node configuration settings Console.WriteLine("# of Triggers: " + node.getNumDatalogSessions()); Console.WriteLine("User Inactivity Timeout: " + node.getInactivityTimeout() + " seconds"); Console.WriteLine("Total active channels: " + node.getActiveChannels().count()); Console.WriteLine("# of sweeps: " + node.getNumSweeps()); //If a configuration function requires a ChannelMask parameter, this indicates that the //option may affect 1 or more channels on the Node. For instance, a hardware gain may //affect ch1 and ch2 with just 1 setting. If you know the mask for your Node, you can just provide //that mask when asking for the configuration. If you want to programatically determine //the mask for each setting, you can ask for the Node's ChannelGroups. See below. mscl.ChannelGroups chGroups = node.features().channelGroups(); //iterate over each channel group foreach (var group in chGroups) { //get all of the settings for this group (ie. may contain linear equation and hardware gain). mscl.ChannelGroupSettings groupSettings = group.settings(); //iterate over each setting for this group foreach (var setting in groupSettings) { //if the group contains the linear equation setting if (setting == mscl.WirelessTypes.ChannelGroupSetting.chSetting_linearEquation) { //we can now pass the channel mask (group.channels()) for this group to the node.getLinearEquation function. //Note: once this channel mask is known for a specific node (+ fw version), it should never change mscl.LinearEquation le = node.getLinearEquation(group.channels()); Console.WriteLine("Linear Equation for: " + group.name()); Console.WriteLine("Slope: " + le.slope()); Console.WriteLine("Offset: " + le.offset()); } } } }
public static void setToIdle(mscl.WirelessNode node) { //call the set to idle function and get the resulting SetToIdleStatus object mscl.SetToIdleStatus status = node.setToIdle(); Console.Write("Setting Node to Idle"); //using the SetToIdleStatus object, check if the Set to Idle operation is complete. // Note: we are specifying a timeout of 300 milliseconds here which is the maximum // amount of time that the complete function will block if the Set to Idle // operation has not finished. Leaving this blank defaults to a timeout of 10ms. while (!status.complete(300)) { //Note: the Set to Idle operation can be canceled by calling status.cancel() Console.Write("."); } //at this point, the Set to Idle operation has completed //check the result of the Set to Idle operation switch (status.result()) { //completed successfully case mscl.SetToIdleStatus.SetToIdleResult.setToIdleResult_success: Console.WriteLine("Successfully set to idle!"); break; //canceled by the user case mscl.SetToIdleStatus.SetToIdleResult.setToIdleResult_canceled: Console.WriteLine("Set to Idle was canceled!"); break; //Failed to perform the operation case mscl.SetToIdleStatus.SetToIdleResult.setToIdleResult_failed: default: Console.WriteLine("Set to Idle has failed!"); break; } }
//Function: getCurrentConfig // This function demonstrates how to obtain the current configuration // settings of a Wireless Node with MSCL. // // Note: More settings are available than are demoed here. // Reference the documentation for the full list of functions. static void getCurrentConfig(ref mscl.WirelessNode node) { Console.WriteLine("Current Configuration Settings"); //read some of the current node configuration settings Console.WriteLine("# of Triggers: " + node.getNumDatalogSessions()); Console.WriteLine("User Inactivity Timeout: " + node.getInactivityTimeout() + " seconds"); Console.WriteLine("Total active channels: " + node.getActiveChannels().count()); Console.WriteLine("# of sweeps: " + node.getNumSweeps()); //get a list of the supported channels mscl.WirelessChannels supportedChannels = node.channels(); //loop through all of the channels foreach (var channel in supportedChannels) { //print out some information about the channels Console.WriteLine("Channel #: " + channel.Key); Console.WriteLine("Slope: " + channel.Value.getLinearEquation().slope()); Console.WriteLine("Offset: " + channel.Value.getLinearEquation().offset()); } }
static void Main(string[] args) { try { //create a Serial Connection with the specified COM Port, default baud rate of 921600 mscl.Connection connection = mscl.Connection.Serial(COM_PORT); //create a BaseStation with the connection mscl.BaseStation baseStation = new mscl.BaseStation(connection); //create a WirelessNode with the BaseStation we created mscl.WirelessNode node = new mscl.WirelessNode(NODE_ADDRESS, baseStation); Console.WriteLine("Attempting to ping the Node..."); //ping the Node mscl.PingResponse response = node.ping(); //if the ping response was a success if (response.success()) { Console.WriteLine("Successfully pinged Node " + NODE_ADDRESS); Console.WriteLine("Base Station RSSI: " + response.baseRssi()); Console.WriteLine("Node RSSI: " + response.nodeRssi()); } else { Console.WriteLine("Failed to ping Node " + NODE_ADDRESS); } } catch (mscl.Error e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Press Enter to quit..."); Console.Read(); }
static void Main(string[] args) { try { //create a Serial Connection with the specified COM Port, default baud rate of 921600 mscl.Connection connection = mscl.Connection.Serial(COM_PORT); //create a BaseStation with the connection mscl.BaseStation baseStation = new mscl.BaseStation(connection); //create a WirelessNode with the BaseStation we created mscl.WirelessNode node = new mscl.WirelessNode(NODE_ADDRESS, baseStation); //create an ArmedDataloggingNetwork object, giving it the BaseStation that will be the master BaseStation for the network mscl.ArmedDataloggingNetwork network = new mscl.ArmedDataloggingNetwork(baseStation); //add a WirelessNode to the network // Note: The Node must already be configured for Armed Datalogging before adding to the network, or else Error_InvalidConfig will be thrown. //TODO: Repeat this for all WirelessNodes that you want in the network Console.Write("Adding node to the network..."); network.addNode(node, "This is an optional <50-char message."); Console.WriteLine("Done."); //start all the nodes in the network sampling. Console.Write("Starting the network..."); network.startSampling(); Console.WriteLine("Done."); } catch (mscl.Error e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Press Enter to quit..."); Console.Read(); }
static void Main(string[] args) { try { //create a Serial Connection with the specified COM Port, default baud rate of 921600 mscl.Connection connection = mscl.Connection.Serial(COM_PORT); //create a BaseStation with the connection mscl.BaseStation baseStation = new mscl.BaseStation(connection); //create a WirelessNode with the BaseStation we created mscl.WirelessNode node = new mscl.WirelessNode(NODE_ADDRESS, baseStation); //create a SyncSamplingNetwork object, giving it the BaseStation that will be the master BaseStation for the network mscl.SyncSamplingNetwork network = new mscl.SyncSamplingNetwork(baseStation); //add a WirelessNode to the network // Note: The Node must already be configured for Sync Sampling before adding to the network, or else Error_InvalidConfig will be thrown. //TODO: Repeat this for all WirelessNodes that you want in the network Console.Write("Adding node to the network..."); network.addNode(node); Console.WriteLine("Done."); //can get information about the network Console.WriteLine("Network info: "); Console.WriteLine("Network OK: " + network.ok().ToString()); Console.WriteLine("Percent of Bandwidth: " + network.percentBandwidth().ToString() + "%"); Console.WriteLine("Lossless Enabled: " + network.lossless().ToString()); Console.WriteLine("High Capacity Mode: " + network.highCapacity().ToString()); //apply the network configuration to every node in the network Console.Write("Applying network configuration..."); network.applyConfiguration(); Console.WriteLine("Done."); //start all the nodes in the network sampling. The master BaseStation's beacon will be enabled with the system time. // Note: if you wish to provide your own start time (not use the system time), pass a mscl::Timestamp object as a second parameter to this function. // Note: if you do not want to enable a beacon at this time, use the startSampling_noBeacon() function. (A beacon is required for the nodes to actually start sending data). Console.Write("Starting the network..."); network.startSampling(); Console.WriteLine("Done."); //======================================================================================= //Many other functions are available for the SyncSamplingNetwork: // //network.lossless() //enable or disable "lossless" mode for the network (default of enabled). //network.highCapacity() //enable or disable "high capacity" mode for the network (default of disabled). //network.ok() //check whether or not the network is "OK" meaning all nodes fit in the network and have communicated successfully. //network.percentBandwidth() //get the percent of bandwidth for the entire network. //network.refresh() //refreshes the entire network. Should be called any time a change is made to the node after it has been added to the network. //network.removeNode() //remove a node from the network. //network.getNodeNetworkInfo() //get network information for an individual node in the network (TDMA address, percent bandwidth, etc.) //======================================================================================= } catch (mscl.Error e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Press Enter to quit..."); Console.Read(); }