void pnlWFMLoader::OnbtnHexClick(wxCommandEvent& event) { vector< pair<int, int> > iq_pairs; if (txtFilename->GetLabel().size() == 0) { wxMessageBox("File not selected", "Error"); return; } ReadWFM(txtFilename->GetLabel(), "output.txt", iq_pairs); int bufferSize = iq_pairs.size() * 2; unsigned short *buffer = new unsigned short[bufferSize]; memset(buffer, 0, bufferSize); short ii = 0; short qq = 0; wxFileDialog dlg(this, _("Save .txt file"), "", "", "txt (*.txt)|*.txt", wxFD_SAVE | wxFD_OVERWRITE_PROMPT); if (dlg.ShowModal() == wxID_CANCEL) return; ofstream fout; fout.open(dlg.GetPath().ToStdString().c_str(), ios::out); int addr = 0; for (unsigned i = 0; i<iq_pairs.size(); ++i) { ii = iq_pairs[i].first; qq = iq_pairs[i].second; ii = (ii & 0xFFF); fout << "x" << addr << "\"" << uint2hex(ii, 2) << "\"," << endl; ++addr; qq = (qq & 0xFFF); fout << "x" << addr << "\"" << uint2hex(qq, 2) << "\"," << endl; ++addr; } fout.close(); }
void pnlWFMLoader::OnbtnMifClick(wxCommandEvent& event) { vector< pair<int, int> > iq_pairs; if (txtFilename->GetLabel().size() == 0) { wxMessageBox("File not selected", "Error"); return; } if (ReadWFM(txtFilename->GetLabel(), "output.txt", iq_pairs) < 0) return; int bufferSize = iq_pairs.size() * 2; unsigned short *buffer = new unsigned short[bufferSize]; memset(buffer, 0, bufferSize); short ii = 0; short qq = 0; wxFileDialog dlg(this, _("Save .mif file"), "", "", "mif (*.mif)|*.mif", wxFD_SAVE | wxFD_OVERWRITE_PROMPT); if (dlg.ShowModal() == wxID_CANCEL) return; ofstream fout; fout.open(dlg.GetPath().ToStdString().c_str(), ios::out); fout << "WIDTH=13;" << endl; fout << "DEPTH=" << iq_pairs.size() * 2 << ";" << endl << endl; fout << "ADDRESS_RADIX=UNS;" << endl; fout << "DATA_RADIX=HEX;" << endl << endl; fout << "CONTENT BEGIN" << endl; int addr = 0; for (unsigned i = 0; i<iq_pairs.size(); ++i) { ii = iq_pairs[i].first; qq = iq_pairs[i].second; ii = (ii & 0xFFF) | 0x1000; fout << "\t" << addr << " : " << uint2hex(ii, 2) << ";" << endl; ++addr; qq = (qq & 0xFFF); fout << "\t" << addr << " : " << uint2hex(qq, 2) << ";" << endl; ++addr; } fout << "END;" << endl; fout.close(); return; }
void usb_send_hex(int ep_id, unsigned int val) { char buf[16]; char * cp = buf;; int n; *cp++ = ' '; *cp++ = '0'; *cp++ = 'x'; n = uint2hex(cp, val); cp += n; *cp++ = '\r'; *cp++ = '\n'; n += 5; usb_send(ep_id, buf, n); }
void uart_send_hex(struct stm32_usart * usart, unsigned int val) { char buf[16]; char * cp = buf;; int n; *cp++ = ' '; *cp++ = '0'; *cp++ = 'x'; n = uint2hex(cp, val); cp += n; *cp++ = '\r'; *cp++ = '\n'; n += 5; uart_send(usart, buf, n); }