차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 | |||
|
ko:bs2_setslavebaudrate [2024/02/22 08:42] kkshin 제거됨 |
ko:bs2_setslavebaudrate [2024/10/23 16:19] (현재) mwkim 만듦 |
||
|---|---|---|---|
| 줄 5: | 줄 5: | ||
| ===== BS2_SetSlaveBaudrate ===== | ===== BS2_SetSlaveBaudrate ===== | ||
| - | [+ 2.9.6] RS485 네트워크에서 슬레이브 장치의 baudrate을 변경합니다. \\ | + | [+ 2.9.8] 마스터 장치에 연결된 슬레이브 장치의 RS-485 전송 속도를 변경합니다. \\ |
| + | 슬레이브와 다시 연결하려면 마스터 장치의 RS-485 전송 속도도 슬레이브의 전송속도와 동일하게 변경해야 합니다. | ||
| ==== 함수 ==== | ==== 함수 ==== | ||
| <code cpp> | <code cpp> | ||
| #include "BS_API.h" | #include "BS_API.h" | ||
| - | int BS2_SetSlaveBaudrate(void* context, BS2_DEVICE_ID deviceId, BS2_DEVICE_ID slaveId, uint32_t baudrate); | + | int BS2_SetSlaveBaudrate(IntPtr context, UInt32 deviceId, UInt32 slaveId, UInt32 baudrate); |
| </code> | </code> | ||
| ==== 파라미터 ==== | ==== 파라미터 ==== | ||
| * [In] ''//context//'' : Context | * [In] ''//context//'' : Context | ||
| - | * [In] ''//deviceId//'' : 마스터 장치 식별자 | + | * [In] ''//deviceId//'' : 장치 식별자 |
| * [In] ''//slaveId//'' : 슬레이브 장치 식별자 | * [In] ''//slaveId//'' : 슬레이브 장치 식별자 | ||
| - | * [In] ''//baudrate//'' : 변경할 baudrate | + | * [In] ''//baudrate//'' : RS-485 통신 속도 |
| ==== 반환값 ==== | ==== 반환값 ==== | ||
| - | 성공적으로 변경했을 경우 ''BS_SDK_SUCCESS''를 반환하고, 슬레이브 장치가 연결되어 있지 않은 경우 ''BS_SDK_ERROR_SLAVE_NOT_READY''를 반환합니다. | + | 성공적으로 수행될 경우 ''BS_SDK_SUCCESS''를 반환하고, 에러가 발생할 경우 상응하는 에러 코드를 반환합니다. |
| - | + | ||
| - | ==== 샘플코드(C++) ==== | + | |
| - | + | ||
| - | <file cpp sample_bs2_setslavebaudrate.cpp> | + | |
| - | int setSlaveBaudrate(void* context, const DeviceList& devices) | + | |
| - | { | + | |
| - | CommControl cm(context); | + | |
| - | + | ||
| - | Utility::displayConnectedDevices(devices, true); | + | |
| - | BS2_DEVICE_ID masterID = Utility::getInput<BS2_DEVICE_ID>("Please enter the master device ID:"); | + | |
| - | BS2_DEVICE_ID slaveID = Utility::getInput<BS2_DEVICE_ID>("Please enter the slave device ID:"); | + | |
| - | + | ||
| - | string msg = "Please select a baudrate. (9600, 19200, 38400, 57600, 115200)"; | + | |
| - | uint32_t baudrate = Utility::getInput<uint32_t>(msg); | + | |
| - | + | ||
| - | return BS2_SetSlaveBaudrate(context_, masterID, slaveID, baudrate); | + | |
| - | } | + | |
| - | </file> | + | |
| - | + | ||
| - | ==== 샘플코드(C#) ==== | + | |
| - | <file csharp sample_bs2_setslavebaudrate.cs> | + | |
| - | public void setSlaveBaudrate(IntPtr sdkContext, UInt32 deviceID, bool isMasterDevice) | + | |
| - | { | + | |
| - | List<UInt32> slaveDeviceList = new List<UInt32>(); | + | |
| - | + | ||
| - | Console.WriteLine("What slave device will the baudrate be set to?"); | + | |
| - | foreach (var slave in searchedSlave) | + | |
| - | { | + | |
| - | Console.WriteLine(" {0} ({1})", slave.Item1, slave.Item2); | + | |
| - | } | + | |
| - | Console.Write(">> "); | + | |
| - | UInt32 slaveID = Util.GetInput((UInt32)0); | + | |
| - | if (0 == slaveID) | + | |
| - | return; | + | |
| - | + | ||
| - | Console.WriteLine("Please select a baudrate. (9600, 19200, 38400, 57600, 115200)"); | + | |
| - | Console.Write(">> "); | + | |
| - | UInt32 baudrate = Util.GetInput((UInt32)9600); | + | |
| - | + | ||
| - | Console.WriteLine("Trying to set slave baudrate."); | + | |
| - | BS2ErrorCode result = (BS2ErrorCode)API.BS2_SetSlaveBaudrate(sdkContext, deviceID, slaveID, baudrate); | + | |
| - | } | + | |
| - | </file> | + | |