コード例 #1
0
ファイル: C2.Flash.cs プロジェクト: x893/C2.Flash
		private bool setStatus(string command, Response response)
		{
			StringBuilder sb = new StringBuilder(command);
			if (response.Result == ResponseCode.COMMAND_OK)
				sb.Append(": OK");
			else
				sb.AppendFormat(": {0} ({1:X2})", response.Result, (byte)response.Result);
			status.Text = sb.ToString();
			return (response.Result == ResponseCode.COMMAND_OK);
		}
コード例 #2
0
ファイル: C2.Flash.cs プロジェクト: x893/C2.Flash
		private Response sendCommand(int response_length, byte[] data, int startIndex, int length, params byte[] package)
		{
			Response response = new Response(response_length);
			if (port != null)
			{
				Application.DoEvents();
				activeResponse = response;

				if (package != null && package.Length > 0)
				{
					port.Write(package, 0, package.Length);
				}
				if (data != null)
				{
					port.Write(data, startIndex, length);
				}
				bool result = response.WaitEvent.WaitOne(5000);
				activeResponse = null;
				if (!result)
					response.Result = ResponseCode.COMMAND_NO_RESPONSE;
			}
			else
			{
				response.Result = ResponseCode.COMMAND_DROP;
			}
			return response;
		}